Step 3: Setup and connect your sensorbox to the web platform
3.0 What you need
3.1 Create a P2PFoodLab account
- Go to https://p2pfoodlab.net/community/createaccount, and fill the form. Click 'create account'.
- Check for the confirmation email. Click on the link in the email.
- You should see you home page on the P2P Food Lab web site.
- Click on the 'account' menu in the top-right corner.
- In the 'OpenSensorData.net' panel, you will find your OpenSensorData key. You will need it in the next section, to configure the sensorbox.
3.2 Configure the RPi
Option 1: Use our install script on a fresh Raspbian installation
1. Install Raspbian on a >4GB CD card. See http://www.raspberrypi.org/downloads. See http://www.raspberrypi.org/documentation/installation/installing-images/README.md for directions to clone the image you get, and https://www.sdcard.org/downloads/formatter_4/ to format SD Card prior of installation.
2. Put the SD card in the RPi and boot the little device. In the blue configuration screen (raspi-config), do the following:
- expand the file system.
- set the graphics card memory to a minimum (16MB) (in "Advanced Options/Memory Split", type 16 instead of 64)
- enable the SSH server (should be enabled by default)
- disable the desktop at startup (in "Enable Boot to Desktop", select "Console Text console")
- Choose the correct keyboard layout in "Change Internationalisation Options"
3. Reboot and log into the RPi. User should be "pi" and password "raspberry" - be careful with your keyboard layout if you didn't select the correct internationalisation option
4. You may want to setup your Wifi dongle and configure your RPi to have remote access over your Wifi Network
5.Then run the following command (it may take a while):
$ wget https://github.com/hanappe/p2pfoodlab/raw/master/rpi/install-p2pfoodlab.sh $ sudo bash install-p2pfoodlab.sh
NOTE: This installation script is meant for Raspberry Pi's that will be used exclusively as a sensorbox. The installation script overwrites existing configuration files without a warning,including the Apache2 configuration files. Don't run the script on a RPi that you're already using for other purposes.
Option 2: use our disk image
- Download the disk image from https://p2pfoodlab.net/wiki/big-files/p2pfl-2014-06-13.img.zip (900 Mo)
- Dezip the file
- Copy the image on your SD Card (Minimal size: 4GB)
- Edit file /boot/p2pfoodlab.json
- Insert SD Card in RPi and boot, login (username:pi, password:raspberry)
- If SD Card is bigger than 4GB, increase image disk by doing
$ sudo raspi-config
and then select the first menu item
3.3 Configure the Arduino
- If you haven't got the latest version of the Arduino development environment installed, then download it here.
- Download the P2P Food Lab code for the Arduino
- Install the two libraries DHT22.zip and Narcoleptic.zip.
- Connect the Arduino to your laptop using a FTDI serial-to-USB cable.
- Start the Arduino IDE. Select the correct serial port in the Tools -> Serial Port menu. Select the "Arduino Pro or Pro Mini (3.3V, 8MHz) w/ ATmega328" in the Tools -> Board menu.
- In Tools > Serial Port menu, make sure you have the right port selected (trial and error?).
- Open the file p2pfoodlab/arduino/p2pfoodlab/p2pfoodlab.ino
- Click "Upload" to transfer the code to the Arduino.
7. Plug in the USB WiFi, the webcam, and then reboot the RPi.
8. Connect the RPi to a laptop/PC using a cross-cable. The laptop should be configured to obtain an IP address automatically using DHCP.
9. Start a web browser and go to the address http://192.168.3.14/ Log in to the configuration web site. The default password is 'p2pfoodlab'.
10. Configure the different sections of the sensorbox:
- The WiFi settings of your network
- Give a name to the sensorbox and provide the OpenSensorData.net key to upload the data
- Set the period with which you want to upload the data, and the webcam photos.
- Add your public SSH key to the SSH section (needed for the optional test below).
On Linux, copy the output of the command below:
$ cat ~/.ssh/id_rsa.pub
If you don't have any SSH keys, you can generate them as follows:
$ ssh-keygen -t rsa
11. To test the communication with the Arduino, ssh into the RPi and execute the following commands:
$ i2cdetect -y 1
This should show the presence of the Arduino at the address 04.
$ /var/p2pfoodlab/bin/arduino millis
This should return the current clock count of the Arduino.
12. To verify that the data upload:
- On the RPi, check the ID of the data group:
$ cat /etc/opensensordata/group.json
- Write down the ID of the group.
- Go to the web page http://opensensordata.net/viewgroup/<ID>.csv
13. Sit back and relax.
3.4 Configuring the sensorbox
You can configure your sensorbox at any time by typing the IP Address of your sensorbox in a web browser.
You can also configure your sensorbox directly by modifying the file /var/p2pfoodlab/etc/config.json
In order to reduce power consumption, we recommend you to use the following guidelines:
- Take a measure every hour
- Take a photo once a day
- Upload data once a day
Like such, the size of the sensorbox memory is just big enough to store the data for a full day and the RPi (which is the biggest power consumer in the setup) will be "alive" only a few minutes per day.
See also https://p2pfoodlab.net/sensorbox/planetelilas/planetelilas/config.json for an example.
For poweruser only
3.5 Updating the software afterwards
Updating the Raspberry Pi: Option 1
- Make sure that the RPi is running. If it has been turned off for power saving, you can boot boot it by bypassing the MOSFET: place a jumper over the two pins in the lower left corner of the board. Alternatively, you can connect a micro USB cable to the power inlet of the RPi.
- Connect the Ethernet cross-cable from your PC to the RPi.
- Your laptop should get an IP address such as 192.168.3.1xx.
- Connect to the web interface at http://192.168.3.14
- Turn off the energy saving setting in the configuration panel, to avoid that the RPi turns itself off.