Unofficial bindings for the GrovePi library, allowing you to write your Raspberry Pi software for GrovePi+ in Ruby!
Add this line to your application's Gemfile:
gem 'grovepi'
And then execute:
$ bundle
Or install it yourself as:
$ gem install grovepi
Read the current temperature:
Grovepi.temperature # => 70
Read the current pH level:
Grovepi.ph # => 6.83
Turn the LED on and off:
Grovepi.led.active = true
Grovepi.led.active? # => true
Grovepi.led.active = false
Grovepi.led.active? # => false
You can also use the "low-level" API to do raw digital and analog reads/writes on the device.
For example, here is how to perform the above LED functions with the
low-level digitalWrite
and digitalRead
calls:
# the LED is off..
Grovepi.digital_read(4) # => 0
# send data bit 1 to port D4 to turn on the LED
Grovepi.digital_write(4,1)
Grovepi.digital_read(4) # => 1
# the LED is now on. send data bit 0 to port D4 to turn off the LED
Grovepi.digital_write(4,0)
Grovepi.digital_read(4) # => 0
This gem requires an installation of Raspbian, and therefore cannot
be compiled on most machines. Provided in this repo is a Dockerfile
which describes how to build a Docker container locally for gem testing.
To build the gem into a Docker container, run:
docker build .
When that's done, you can now run tests in your container:
docker run 'bin/rake test'
You can also get a console in your container:
docker run 'bin/console'
Bug reports and pull requests are welcome on GitHub at https://github.com/tubbo/grovepi. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
This Ruby gem is available as open source under the terms of the MIT License. The GrovePi C++ code is Copyright (C) 2017 Dexter Industries.
Everyone interacting in the Grovepi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.