From P2P Food Lab
Jump to: navigation, search



The sensor box is made from standard off-the-shelf components, with a bit of soldering and DIY work. It uses a both an Arduino and a Raspberry Pi. The reason for this design is that the Raspberry Pi is really handy to plug in USB devices such as the webcam and the wireless communication devices (WiFi or GSM).

The printed circuit board from Express PCB
The PCB + Arduino Mini Pro + the RHT03 sensor
Work-around for the errors in the first version of the design...
Battery + Raspberry Pi + PCB + Arduino + GSM key + webcam

However, it consumes too much energy to run on a battery. That's where the Arduino comes in handy. The Arduino takes the measurements. It also wakes up the Raspberry Pi once or twice a day, to take a photo snapshot and to upload the data to the web server. The Arduino and the Raspberry Pi communicate over I2C. This set-up gives a lot of flexibility. The modularity of both the Arduino and the Raspberry Pi allow everyone to plug in different devices and sensors.

The sensors

The list of sensors includes:

  • the webcam
  • the greenhouse temperature and humidity
  • the soil humidity
  • the external temperature and humidity
  • the illuminance

The list of actuators includes the watering system (pump or valve). We may add an air trap also.

The basic design



The circuit board

To connect all the parts together, I developed a small board. Currently, it's still a two-sided board, but I will try to make it it one-sided so it is "FabLab'able". Below is the design (version 1).


Copyright: Sony Computer Science Laboratory Paris - License: GPL v3 - Author: Peter Hanappe.

The battery

There are many USB recharger batteries on the market today, many of which have an integrated solar panel. I've tested a number of them and so far I havent' found any model that suits the needs of the sensorbox. Here are the problems I encountered:

  • Powering the RPi: The battery fails to provide enough current for the RPi. Because of the USB WiFi antenna, the webcam, and - possibly - the ethernet connection, the amount of current that the RPi draws is significant.
  • Stays awake (or battery not sleepy): When the RPi is shut down, the only device left running is the Arduino Pro Mini. However, the Arduino draws so little current that many of the batteries go into sleeping mode...
  • use & charge: Many batteries with an integrated solar battery are either in charge or in use mode, but not both. So it is not possible to run the Arduino continuously while the battery is charging at the same time.

Here's the list of batteries tested so far:

Model Cost Capacity Output current Dimensions Weight Power RPi Stays awake Solar Use & charge
Telstar 1000 mAh no yes yes ?
Rimax Universal Sun Charger 2500 mAh 0.5 A yes ?
Watt & Co MF1600 75 € 3600 mAh 0.6 - 2.0 A 7 x 1.7 x 12.5 cm 160 g no (yes without USB devices) yes yes ?
Solar ReStore XL 36 € 4000 mAh I < 2.1 A 17.1 x 9.2 x 2.1 cm 227 g yes yes yes no (charging/out switch)
EasyAcc Power Bank PB 10000 31 - 75 € 10.000 mAh 1.0 - 2.0 A 14 x 7.5 x 1.8 cm 260g yes no no
EasyAcc Power Bank PB5600 24 - 67 € 5600 mAh 1.0 A 9.3 x 2.2 x 4.3 cm 127 g yes no no
Opteka Solar Charger BP-SC4000 28 € 4000 mAh 1.0 A 11.4 x 8.4 x 1.4 cm 185 g yes yes yes yes

The bill of materials

(Links to Farnell France & Sparkfun):

For the printed circuit board:

Description Reference Quantity Unit cost (euro) Total cost (euro)
The basic board
Arduino Arduino Pro Mini 328 3.3V 8mHz 1 12 12
Raspberry Pi Raspberry Pi 1 28 28
Raspian SD Card RASPBERRY-PI / PROG-4GB-SDCARD 1 10.50 10.50
USB Connector USB2066-05-RBHM-15-STB-00-00-A 1 1.05 1.05
26-way female board-to-board connector SAMTEC - BCS-113-L-D-TE 1 5.90 5.90
1-row 12-way socket MULTICOMP - 2212S-12SG-85 2 1.27 2.54
Pins arduino to 12-way socket Header pins 2.54MM 36WAY 1 1.51 1.51
MOSFET STU95N2LH5 1 0.72 0.72
0.1 uF (film?) capacitor 0.1uF capacitor type 0805 1 0.43 0.43
On board temperature and humidity sensor
Humidity and Temperature Sensor RHT03 / DHT-22 1 14 14
4k7 resistance RESISTANCE 0805 4K7 1 0.041 0.041
Remote temperature and humidity sensor
Humidity and Temperature Sensor RHT03 / DHT-22 1 14 14
4-way connector BG300-04-A-L-A 1 1.00 1.00
4k7 resistance RESISTANCE 0805 4K7 1 0.041 0.041
Pins Header pins 2.54MM 1 1.51 1.51
Telephone wire
High-quality temperature and humidity sensor (option for two sensors)
Sensor SHT15 1 >40 >40
4-way connector BG300-04-A-L-A 1 1.00 1.00
Pins Header pins 2.54MM 1 1.51 1.51
Telephone wire
Light sensor
Light sensor OSRAM SFH 203 P 1 1.07 1.07
390 Ohm Resistance 390 Ohm 0805 type 1 0.017 0.017
To connect a pump
Screw PCB Terminal Multicomp MC000018 2 0.70 1.40
MOSFET STU95N2LH5 1 0.72 0.72
Header pins 3-way Header pins 2.54MM 1 1.51 1.51
Jumper 2-way jumper 1 0.31 0.31
Soil humidity sensor
Screw PCB Terminal Multicomp MC000018 1 0.70 0.70
555 timer chip LMC555CM 1 1.13 1.13
390 Ohm Resistance 390 Ohm 0805 type 1 0.017 0.017
150 kOhm Resistance 150 kOhm 0805 type 1 0.009 0.009
2.2 uF capacitors 2.2uF capacitor type 0805 2 0.37 0.74
USB WiFi Dongle D-LINK DWA-127 1 20 20
or USB GSM Dongle Huawei E176 1 31 31
Logitech C310 1 35 35

All the sensor data is currently uploaded to

The software

The software for the sensorbox is maintained at GitHub.

The code for the Arduino is a standard Arduino project.

The code for the Raspberry Pi covers the web interface (see next section), tools written in C to communicate with the Arduino and the webcam, and a set of scripts to update the system settings (network, crontab, ssh, ...).

Some of the system update scripts require super-user privileges. To bridge between the PHP web interface (running as user 'www-data') and the update scripts (executed as 'root') we developed a small HTTP server that listens on the loopback interface. Code: daemon.c

We developed a small utility to talk to the arduino. The program is called 'arduino'. Code: arduino.c:

 $ arduino --help
 arduino [command] [options]
 - enable-sensors flags     Enable sensors
 - store-data               Download and store sensor data
 - poweroff minutes         Shutdown the Raspberry Pi
 - millis                   Get the current clock
 - pump seconds             Turn on/off the pump

The web interface



Sensorbox for Todoroki farm, Tokyo

Sensorbox shown at the Maker Faire Rome & St Malo