Sensorbox Version 2.1

From P2P Food Lab
Jump to: navigation, search

Overview

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 (not on the WOMA model)
  • 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

Setup-9-bis.png

References

The circuit board

To connect all the parts together, four small boards have been developped. 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).

Main PCB

((Mettre à jour))

RHT03 (Temperature sensor) PCB

((Mettre à jour))

Lightsensor PCB

((Mettre à jour))

Pump PCB

((Mettre à jour))

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

The bill of materials

For the printed circuit board

Aggregator node

The basic board
Type References & Dimensions Quantity Unit price Total price
Arduino Pro Mini 328 3.3V 8MHz Arduino Pro Mini 328 3.3V 8mHz 1 12€ 12€
FTDI Basic Breakout 3.3V Sparkfun Basic Breakout 3.3V 1 11€ 11€
Raspberry Pi Model B Raspberry Pi 1 28€ 28€
Raspian SD Card RASPBERRY-PI / PROG-4GB-SDCARD 1 10.5€ 10.5€
USB cable, M/F, 25cm [1] 1 1.09€ 1.09€
USB Connector USB2066-05-RBHM-15-STB-00-00-A / To connect the solar panel 1 1.05€ 1.05€
26-way female board-to-board connector SAMTEC - BCS-113-L-D-TE 1 5.9€ 5.9€
1-row 12-way header pins Header pins 2.54MM 36WAY / To connect the Arduino to the main board 2 1.27€ 2.54€
1-row 6-ways header pins (bended) Header pins 2.54MM 36WAY / used to connect the FDTI to the Arduino 1 1.51€ 1.51€
JST-3 header B3B-PH-K-S / Used to connect the sensors to the main board 4 0.15€ 0.60€
MOSFET STU95N2LH5 1 0.72€ 0.72€
Main PCB ND 1 ND ND
Resistance 100 MOhms [2] 2 1€ 2€
TOTAL 76.91€ + PCB
Networking options
Networking
Type References & Dimensions Quantity Unit price Total price
Option 1: USB WiFi Dongle D-LINK DWA-127 1 20€ 20€
Option 2: USB GSM Dongle with SIM Card Huawei E176 1 31€ 31€
Option 3: Ethernet On board 1 0 0
Options to power the aggretator node
Power
Type References & Dimensions Quantity Unit price Total price
Solar panel Opteka Solar Charger BP-SC4000 (4000 mAh, 1.0A, 11.4 x 8.4 x 1.4 cm) 1 28€ 28€
AC/DC adaptor 5V 1A AC/DC adaptor 1 4.43€ 4.43€

Temperature and Humidity Sensors

Option 2: Remote temperature and humidity sensor
Type References & Dimensions Quantity Unit price Total price
Humidity and Temperature Sensor RHT03 / DHT-22 1 14 14
JST-3 header B3B-PH-K-S / Used to connect the sensors to the main board 1 0.15€ 0.15€
4k7 resistance RESISTANCE 0805 4K7 1 0.041€ 0.041€
JST-3 header plug JST-3 header plug 1 0.05€ 0.05€
3-way wire
TOTAL 14.15€


Option 3: High quality temperature and humidity sensor (options for two sensors)
Type References & Dimensions Quantity Unit price Total price
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
Sensor PCB ND ND ND ND
TOTAL xxx

Other sensors

Light sensor
Type References & Dimensions Quantity Unit price Total price
Light sensor OSRAM SFH 203 P 1 1.07 1.07
390 Ohm Resistance 390 Ohm 0805 type 1 0.017 0.017
TOTAL xxx


Pump & Pump connection
Type References & Dimensions Quantity Unit price Total price
Pump Reference needed  ?  ?  ?
Water flexible Reference needed  ?  ?  ?
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
JST-2 header B2B-PH-K-S 1 0.12€ 0.12€
Jumper 2-way jumper 1 0.31 0.31
Pump PCB ND ND ND ND
TOTAL xxx


Soil humidity sensor
Type References & Dimensions Quantity Unit price Total price
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
TOTAL xxx


Camera
Type References & Dimensions Quantity Unit price Total price
Webcam Logitech C310 1 35 35

Protection box

Option 1: Plastic box
Description Reference Quantity Unit cost (euro) Total cost (euro)
Box to protect external humidity sensors ND ND ND ND
Plastic box solution
Option 2: Wood box
Description Reference Quantity Unit cost (euro) Total cost (euro)
Plywood 25cm x 65 cm, 5mm ND ND ND ND
Wood box solution

Other materials (to be reviewed by Peter)

Description Reference Quantity Unit cost (euro) Total cost (euro)
The basic board
USB Mini cable ND ND ND ND
Ethernet cross cable ND ND ND ND
3 x 1-way wire, LIY, 15cm ND ND ND ND
3-way protected wire, 200cm ND ND ND ND
2 x 1-way wire, LIY, 5cm ND ND ND ND
AAA batteries and Battery holder, 3xAAA (optional ?) ND ND ND ND
Male header, 6-way ND ND ND ND
JST-2 plug ND ND ND ND
JST-2 header ND ND ND ND
JST-3 plug ND ND ND ND
JST-3 header ND ND ND ND
JST-4 plug ND ND ND ND
JST-4 header ND ND ND ND
Resistance for lightsensor, 12 kOhm (??? 390 Ohm in the bill of material) ND ND ND ND
Transistors for lightsensor (??? Not in the bill of material) ND ND ND ND
FRAM ND ND ND ND
Jumper ND ND ND ND
Male headers (breakable) 2x12, 1x2, 1x3 ND ND ND ND
Terminal block, 2 way, 3.81mm ND ND ND ND
Screw & bolts ND ND ND ND
Washers ND ND ND ND
Wood screws to fix lightsensor ND ND ND ND
Spacers & screws ND ND ND ND

OpenSensorData.net

All the sensor data is currently uploaded to OpenSensorData.net.


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]
 Commands:
 - 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


I2C

Linux: C-interface <linux/i2c-dev.h> Arduino: Wire library

Keeping time

The Raspberry Pi does not have a "real time clock". This means that it does not know the current time when it starts.

It updates its time by asking another machine on the network, using the Network Time Protocole (NTP). For remote usage, over GSM networks for example, NTP is not reliable. The software package "fake-hwclock" assures that clock is set to the date and time that the RPi shut down.

We improved this strategy by adjusting the RPi clock using arduino's clock.

The web interface

Softwarestack.png

Photos

Sensorbox for Todoroki farm, Tokyo

Sensorbox shown at the Maker Faire Rome & St Malo