Grove sensors are a plug and play way to add sensors, buttons, displays, and actuators to your electronics projects, without soldering. Let’s take a look how well they work when paired with a Raspberry Pi!
I have talked about Grove before. Increasingly I am finding these parts a convenient way to build projects. No soldering, there are usually decent libraries, or at least code snippets, and far fewer wires involved because the majority of the sensors use either I2C or simple analog/digital connections, rather than a mess of breadboard connections.
Up to know, however, I have used Grove with Arduino and the BBC micro:bit. This time around I am using Raspberry Pi and the GrovePi add-on.
As you would expect, GrovePi allows you to plug in digital, analog, serial, and I2C Grove sensors, but it is a little more than that.
What makes GrovePi special is that it’s actually kind of an Arduino that you strap to your Raspberry Pi.
This means you don’t have to worry about the Pi being 3v, and it allows the Pi to read analog inputs.
Unfortunately, it also means it is not as cheap as it would be otherwise. What you trade dollars for you get back in convenience.
There are both full sized and Zero sized boards. I went with the full sized because the Zero version only has 6 sockets. Now I am thinking of getting the Zero version too!
Grove + Python
The Python libraries seem to be less of a priority than the Arduino code, possibly because GrovePi is not a Seeed product, but a third party add-on.
Dexter Industries have their own version of Raspbian that you will need to install to get everything they provide. Adding to an existing Raspbian image seemed to not work so well, but that might have been partly because I also needed to update the firmware.
The main library for handling the basic stuff is the GrovePi module.
This makes working with digital inputs super familiar to Arduino programmers:
import grovepi grovepi.pinMode(3, "INPUT") button1 = grovepi.digitalRead(3)
More complex modules have their own specialized libraries, such as the RGB Backlit LCD display:
import grove_rgb_lcd # 4xLED plugged into pin 5 display = 5 grovepi.pinMode(display, "OUTPUT") grovepi.fourDigit_init(display) grovepi.fourDigit_brightness(display, 8) grovepi.fourDigit_number(display, 1234, False)
Some modules don’t have official libraries, but due to the fact they are usually standard digital or analog, or will have I2C libraries somewhere, you can get them to work.
For example, my LSM6DS3 based 6-Axis Accelerometer and Gyroscope sensor does not have a library, but someone had made a library for a directly connected unit that still works, I just had to tell it the correct I2C address to use.
sudo i2cdetect -y 1
Get the full code for my demo here.
See it in action in my shaky one-handed video: