Grove Pi
Controlling hardware on the Raspberry Pi with NodeJS
This blog is to catalogue my experience setting up a new Raspberry Pi 3 with a set of Grove tools.
Introduction
Grove is the brand name for a range of sensors and devices which share a certain standardised socket. The magic comes from the ability to plug directly into special shields. While more expensive than using a breadboard, Grove makes prototyping faster and less error prone.
https://www.dexterindustries.com/grovepi/
They were originally designed for Arduino pin headers, but they are also compatible with Netduino, Beaglebone, Intel Edison and Raspberry Pi. Each device has its own special Grove drivers and collectively they share a number of shields.
Important Note: All projects which use Grove sockets are possible using non-Grove devices. This requires the technical know-how to wire these devices to the correct pins on the Raspberry Pi and care of pull-up/pull-down resistor requirements. The GrovePi merely takes care of this for us.
Choosing a Raspberry Pi
The Grove Shield supports all full-sized Raspberry Pi variants, since version 1.0b all full Raspberry Pis have shared the same pinout.
The smaller, cheaper and more energy-efficient Raspberry Pi Nano could be used once a project has been successfully validated and the software has been tested.
Bill of Materials
- 1 Raspberry Pi 3 ($35.00)
- 1 NOOBs SD card ($3.00)
These are both available via the Raspberry Pi Foundation’s resellers. Any full-sized RPi will do.
- Grove Pi Shield ($60.00)
- Grove Starter Kit ($80.00)
These are both available from Seeed Studio and resellers.
Installation:
Order the NOOBS SD-Card. Trust me :). It comes with the latest built-in Raspbian image, along with the option install a number of others over network.
For this tutorial I used Raspbian Pixel v4.0.
Setting up SSH
If you have a machine that you normally program on, is recommended to enable SSH on the Raspberry Pi which allows you to access the command-line remotely. This will also allow you to update the software once it is deployed without needing to re-attach a monitor, keyboard and mouse :).
Since Pixel was updated, SSH is no longer on by default, meaning that you either need to enable it in the installed OS via monitor+keyboard+mouse, or by writing a file named ssh
to the boot partition of the SD card. More info =here=.
Grove Pi Software
Grove Pi supplies a set of libraries for the various sensors and devices that they sell.
There are numerous languages to use, each with varying support. Python has the most example projects, and is a great start if you’re new to hardware. I chose to use Javascript as it’s currently the language I want to practice the most :).
Installing NodeJS
The version of NodeJS shipped with Raspbian is out of date and won’t run GrovePi libraries. Additionally, npm
is not installed by default. Update the version of NodeJS via the instructions on the NodeJS website. NodeJS versions can be switched by using version managers like nvm
or n
or by modifying the PATH directly.
All examples here were tested using Node version 7.x.
Confirm the installed version by running node -v
from the command line.
Installing the Grove Pi Software
I followed the manual steps here https://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/setting-software/.
Documentation for the NodeJS libraries is available =here=.
Note that to use the NodeJS software, you will need to navigate to the lib directory and run npm install
. This will install any nodejs dependencies. If this does not complete then it’s possible that the ‘activated’ version of NodeJS is outdated, please see the previous steps.
Testing the software
Next navigate to the /test
folder and run the file with node, e.g. node test.js
. Ensure that the Grove devices are connected to the right pins.