• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
Maker Hacks

Maker Hacks

Ideas, news & tutorials for makers and hackers – Arduino/Raspberry Pi, 3D printing, robotics, laser cutting, and more

  • Home
  • About
  • YouTube
  • Recommendations
  • Contact

Using Grove Sensors, Buttons, and Displays, with Raspberry Pi and Python

You are here: Home / Hacks, Tips, and Tutorials / Using Grove Sensors, Buttons, and Displays, with Raspberry Pi and Python
FacebookTweetPin
Author: Chris Garrett

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!

GrovePi Gyro, Buttons, Displays

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!

Previously

Playing with Grove – LCD Displays

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.

GrovePi

GrovePi

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 i2c addresses in linux
get i2c addresses from linux

Code

Get the full code for my demo here.

See it in action in my shaky one-handed video:

 

Related

Category: Hacks, Tips, and TutorialsTag: electronics, linux, making, programming, python, raspberry pi
FacebookTweetPin

About Chris Garrett

Marketing Director by day, maker, retro gaming, tabletop war/roleplaying nerd by night. Co-author of the Problogger Book with Darren Rowse. Husband, Dad, 🇨🇦 Canadian.

Check out Retro Game Coders for retro gaming/computing.

☕️ Support Maker Hacks on Ko-Fi and get exclusive content and rewards!

Previous Post:Linux Automation Scheduling and Starting Scripts on BootLinux Automation Tips: Running Scripts Automatically
Next Post:Linux Automation Tips: Create a Boot/Start Menu with Pythonpi entertainment centre

Sidebar

  • Facebook
  • Twitter
  • Instagram
  • YouTube

Recently Popular

  • Gweike Cloud Review
  • How to choose the right 3D printer for you
  • Glowforge Review – Glowforge Laser Engraver Impressions, Plus Glowforge Versus Leading Laser Cutters
  • Original Prusa i3 Mk3S Review
  • Best 3D Printing Facebook Groups
  • Elegoo Mars Review – Review of the Elegoo Mars MSLA Resin 3D Printer
  • Glowforge ‘Pass-Through’ Hack: Tricking the Front Flap of the Glowforge with Magnets to Increase Capacity
  • How to Make a DIY “Internet of Things” Thermometer with ESP8266/Arduino
  • Wanhao Duplicator i3 Review
  • IKEA 3D Printer Enclosure Hack for Wanhao Di3
  • Creality CR-10 3d printer review – Large format, quality output, at a low price!
  • 3D Printed Tardis with Arduino Lights and Sounds
  • Anet A8 Review – Budget ($200 or less!) 3D Printer Kit Review
  • Make your own PEI 3D printer bed and get every print to stick!
  • Upgrading the Wanhao Di3 from Good to Amazing
  • How to Install and Set Up Octopi / Octoprint
  • Creality CR-10 S5 Review

Copyright © 2023 · Maker Hacks · All Rights Reserved · Powered by Mai Theme