This article was translated to English, and was originally published for deviceplus.jp.
In this article, I’d like to show how to use a mechanism called Grove from Seeed, with which you can easily add sensors. We’ll build a compact environment check device that lets you use various sensors just by plugging them in and control them from Raspberry Pi.
・Compact lithium polymer battery
(*Caution: Handle with sufficient care and use at your own risk)
・Case for Raspberry Pi Zero (You can start right away with the Raspberry Pi Starter Kit that includes a case.)
1. Use Grove Sensor
2. Use 4-Digit Display
3. Assemble Compact Environment Check Device
This time, I’ll use Seeed ReSpeaker for Raspberry Pi Hat. If you haven’t set up the driver yet, please see Seeed page to set it up beforehand.
ReSpeaker has two Grove terminals. The Grove series are a sensor family from Seeed, which can be used just by plugging them into the terminals without soldering.
Seeed offers more than 100 types of sensors with the Grove terminal, covering most sensors.
Let’s select from sensors that are easy to use with Raspberry Pi.
First, I’ll pick the temperature and humidity sensor, a staple item. It uses a sensor called DHT11 to measure temperature and humidity. The square blue sensor is attached to the board. Four Grove terminals come out on the board.
It’s very handy because you only have to plug them into four unified Grove terminals, while you would normally need to set up a resistor and circuit and connect the power supply, GND, and output by each when using a temperature/humidity sensor.
I’ll insert this sensor into the Grove terminal on the left side as shown in the picture below.
Seeed also provides software to handle the sensor with Raspberry Pi. Turn on Raspberry Pi and connect to it with SSH. See Github page of Seeed to install grove.py by referring to the red frame below.
Here, the grove.py program group is installed in Raspberry Pie with Python3.
$ git clone https://github.com/Seeed-Studio/grove.py
$ cd grove.py
$ sudo pip3 install .
$ cd grove
When the installation is complete, you can see that various programs are stored in a folder called grove. We’ll use grove_temperature_humidity_sensor.py here. Write a simple program as shown below to measure temperature and humidity using DHT11. Specify the Grove terminal on the left side of ReSpeaker as it is connected to GPIO3.
[Sample program grove_temp.py]
Then, use the python3 command to run the program:
$ python3 grove_temp.py
How’s it like? The sensor should be able to measure temperature and humidity once every few seconds and display the value on the screen.
You see that you can easily measure temperature and humidity just by plugging in Grove and using the sample program?
We already measured temperature and humidity, and I’d like to display it. Grove also provides a 4-digit LCD display which you can easily display numerical values.
This LCD display also has four terminals coming out on the board. Connect the display to the middle terminal of ReSpeaker.
There is also a sample program for the 4-digit display, so we’ll apply it. Write a sample program as shown below:
As you run the program, the current time is displayed. We can use the data display simply by connecting it. Pretty straightforward.
$ python3 grove_4d.py
Now, let’s enable the LCD to display the temperature and humidity measured earlier.
Create the grove_temp_4d.py program combining grove_temp.py and grove_4d.py written earlier.
Then run the program. Time, temperature, and humidity would be displayed alternately.
$ python3 grove_temp_4d.py
Finally, assemble those components into a compact device that can be hung from your neck or placed next to your computer.
We’ll also make the device periodically record the measurements in Google Spreadsheet so you can see under what environment (temperature and humidity) you are spending the day. It may be a good opportunity to review the usual situation of your room!
First, connect a small lithium-ion battery to the Raspberry Pi Zero.
Then, place the Grove temperature and humidity sensor and LCD so that they fit well.
I put them in a case I bought at local store. Attach a gem clip to the back of this case, and you can get the environment check device!
Finally, let’s add a function to periodically upload measurements to Google Spreadsheet. Using the IFTTT mechanism, you can easily upload data from Raspberry Pi to Google Spreadsheet.
Go to the IFTTT.com page to create a new applet.
Select Webhooks as a trigger. Specify an appropriate Event Name (rpzero_temp).
Then, select Google Spreadsheets as Action.
Select “Add row to spreadsheet” to add a row to the spreadsheet each time the device measures temperature and humidity.
You can leave the data definition as default as shown below.
Now we have an applet that writes data to a spreadsheet when it receives an event called “rpzero_temp” from Raspberry Pi.
Click on Webhooks and copy your account key (a string in black shown below). You’ll set this key in your Raspberry Pi.
Now, incorporate this connection information into the Raspberry Pi program as IFTTT_URL and IFTTT_KEY.
Set the data received from the temperature and humidity sensor to Value1, 2, and 3 for the passed data.
If you run the program, the data will periodically be stored in Google Spreadsheet.
Attach the device to the side of your computer and check the temperature and humidity in your room or your surroundings.
Here is the result of using the device for one day. The data stored on Google Spreadsheet can be easily displayed in charts, which is useful for checking the environment.
We connected the Grove sensor to Raspberry Pi Zero and ReSpeaker Hat.
I think that you can easily connect a temperature and humidity sensor or an LCD. Sample programs also enable you to measure and display the environment with ease.
The Grove sensors include sound, light, air cleanliness sensors, etc. You can use any of them according to what you want to measure.
Next time, we are proceeding to a more convenient gadget, a small device in the room to operate an air conditioner and a television.
I’ll see you then!