EXPLORATION TOOLS

 

Instructions on “How to assemble the Sensair” here:

BILL OF MATERIALS

M-01 Recycle plastic bottle – 0€

M-04 2 x BME280 temperature, barometric pressure and humidity sensor – 4,26

 

M-05 SOLAR PANEL WITH LITHIUM ION POLYMER BATTERY (MICRO USB) – 29,99 €

 

M-06 SD CARD (32GB) 17,99 €

M-07 Cables & connectors USB 2.0 to USB 2.0 Micro cable – 4,49 €

 

M-08 CABLE FOR CONNECTING THE SENSORS – 4,99 €

M-09 PIN HEADER – 0,44 €

M-10 USB WIFI DONGLE – 13,49 €

 

2  ASSEMBLY

1 Solder the 2 BME280 sensors…***
2 Connect the Raspberry Pi camera module and USB wi-fi dongle as shown
3 Install the code on the SD card and insert into the SD card port
4 You are now good to go! Plug the Pi into the solar battery pack (or another power source) to start broadcasting the Aerocene backpack wi-fi signal. Log in with your favourite device and point your browser to 172.24.1.1 to interface with the Pi and take a look at the data from the sensors and images from the camera.

***
Because both of the BME280 sensors connect to the Raspberry Pi through the same pins you will need to change the I2C address for the internal sensor so that the Pi can tell the two apart. 

By default, the i2c address is 0x77.  If you slice the trace to GND and solder a new jumper to VCC, the address will change to 0x76. Learn more from here

 

3  SOFTWARE INSTALLATION

The Aerocene backpack Sensair is controlled by a Raspberry Pi running several pieces of open source software – Raspberry Pi wifi hotspot, Raspberry Pi camera web interface, drivers for BME280 sensor – hacked together. Once you’ve assembled your Sensair, these instructions talk you through the process of setting everything up the software from scratch.

GET SET UP

1 Install Raspian on your SD card

Download the Raspian operating system (Raspian Jesse Lite) from the Raspberry Pi website. You will need and SD card reader and an image writing tool (the Raspberry Pi website suggests options for different operating systems if you don’t already have one). Flash the image to the SD card and insert it into the SD card slot of your Raspberry Pi.

2 Get access to your Raspberry Pi’s command line

There are different ways to interface with your Raspberry Pi. The easiest is to connect a HDMI monitor, USB keyboard and mouse, and USB micro power supply directly to your Raspberry Pi. Alternatively, you can set up SSH for remote access to the Raspberry Pi’s command line from your computer via ethernet connection. If this is the first time you are using it, you will need to find your Raspberry Pi’s IP address. Boot up your Raspberry Pi and log in (Username: pi; Password: raspberry)

3 Update and Upgrade your Raspberry Pi

Enter the following two commands, one after the other, to update your Raspberry Pi to the latest version of the Raspian operating system.

sudo apt-get update
sudo apt-get dist-upgrade

4 Configure your Raspberry Pi

Type and enter the following command to access the Raspberry Pi configuration tool:

sudo raspi-config

Use arrow keys to navigate the menu and configure the following settings:
          Expand your filesystem – enable
          Change user password (optional)
          Enable camera – enable
          Advanced options > I2C – enableFinish and reboot

INSTALL AND CONFIGURE SOFTWARE PACKAGES

5 INSTALL AND CONFIGURE WIFI HOTSPOT PACKAGE

Adapted from instructions from Philip Martin.
Install the following 2 packages by entering the command,

sudo apt-get install dnsmasq hostapd

Configure interfaces by making the following edits

sudo nano /etc/dhcpcd.conf

Add the following line at the bottom of the file:

denyinterfaces wlan0

Ctrl ‘o’ enter (to save)
Ctrl ‘x’ enter (to exit)

sudo nano /etc/network/interfaces

Edit the wlan0 section so that it looks like this:

allow-hotplug wlan0  
iface wlan0 inet static
address 172.24.1.1
netmask 255.255.255.0
network 172.24.1.0
broadcast 172.24.1.255
#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Ctrl ‘o’ enter (to save)
Ctrl ‘x’ enter (to exit)

sudo service dhcpcd restart 
sudo ifdown wlan0; sudo ifup wlan0

Configure hostapd by creating the following new config file

sudo nano /etc/hostapd/hostapd.conf 

Copy and paste the following:

# This is the name of the WiFi interface we configured above interface=wlan0
# Use the nl80211 driver with the brcmfmac driver driver=nl80211 # This is the name of the network ssid=aerocene-explorer # Use the 2.4GHz band hw_mode=g # Use channel 6 channel=6 # Enable 802.11n ieee80211n=1 # Enable WMM wmm_enabled=1 # Enable 40MHz channels with 20ns guard interval ht_capab=[HT40][SHORT-GI-20] # Accept all MAC addresses macaddr_acl=0 # Use WPA authentication auth_algs=1 # Require clients to know the network name ignore_broadcast_ssid=0
Ctrl ‘o’ enter (to save)
Ctrl ‘x’ enter (to exit)

Check if it’s working by running

sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf. 

If it’s all gone well so far, you should be able to see the network aerocene-explorer!
Use Ctrl+C to stop it.

Tell hostapd where to look for the config file when it boots up.

sudo nano /etc/default/hostapd

Find the line #DAEMON_CONF=”” and replace it with:

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Ctrl ‘o’ enter (to save)
Ctrl ‘x’ enter (to exit)

Configure dnsmasq by making a new config file

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.conf 

Copy and paste the following:

 
interface=wlan0# Use interface wlan0
listen-address=172.24.1.1 # Explicitly specify the address to listen on
bind-interfaces# Bind to the interface to make sure we aren't sending things elsewhere
server=8.8.8.8 # Forward DNS requests to Google DNS
domain-needed# Don't forward short names
bogus-priv # Never forward addresses in the non-routed address spaces.
dhcp-range=172.24.1.50,172.24.1.150,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time

Ctrl ‘o’ enter (to save)
Ctrl ‘x’ enter (to exit)

[Skip the section “Setup IPV4 fowarding”]

The last job is to start everything:

sudo service hostapd start
sudo service dnsmasq start 

6 INSTALL atmospheric sensor drivers

Return to home directory and install the Adafruit python GPIO package then the Adafruit driver for the BME280 atmospheric sensor using the following commands.

cd
sudo apt-get install build-essential python-pip python-dev python-smbus git
git clone https://github.com/adafruit/Adafruit_Python_GPIO.git
cd Adafruit_Python_GPIO
sudo python setup.py install
cd
Git clone https://github.com/adafruit/Adafruit_Python_BME280.git
cd Adafruit_Python_BME280/
nano Adafruit_BME280.py

Edit the script that returns sensor data for a single timepoint so that it can return data for both of the two sensors (connected via the two I2C addresses, 0x76 and 0x77)  

nano Adafruit_BME280_Example.py

Replace the contents of the file with the following:

 

#!/usr/bin/env python

from Adafruit_BME280 import *

for i in range(2):
sensor = BME280(mode=BME280_OSAMPLE_8, address=0x76+i)

degrees = sensor.read_temperature()
pascals = sensor.read_pressure()
hectopascals = pascals / 100
humidity = sensor.read_humidity()

if i:
print ‘’
print ‘Inside’ if i else ‘Outside’
print ‘Temp= {0:0.3f} deg C’.format(degrees)
print ‘Pressure= {0:0.2f} hPa’.format(hectopascals)
print ‘Humidity= {0:0.2f} %’.format(humidity)

Ctrl ‘o’ enter (to save)
Ctrl ‘x’ enter (to exit)

Test it by running the following command:

python Adafruit_BME280_Example.py

If it’s working you’ll see something like this:

pi@raspberrypi:~/Adafruit_Python_BME280 $ python Adafruit_BME280_Example.py
 
Sensor= 0x76

 

Temp= 25.655 deg C

Pressure= 1006.47 hPa

Humidity= 42.41 %

Sensor= 0x77

Temp= 22.424 deg C

Pressure= 1007.02 hPa

Humidity= 49.62 %

7 INSTALL and edit the rpi camera web interface

The Aerocene backpack Sensair uses the Raspberry Pi Camera web interface developed by Silvan Melchoir and adapts it to also show data from the two atmospheric sensors.
To clone code directly from github, install git-core:

sudo apt-get install git

Then install the Raspberry Pi Camera web interface with the following commands, as described in the installation instructions.

git clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git
cd RPi_Cam_Web_Interface
chmod u+x *.sh
./install.sh

Edit the interface index.php file in nano (the default text editor for the Raspian command line).

cd
cd /var/www
sudo nano index.php

Enter the following code:

 
 

Ctrl ‘o’ enter (to save)
Ctrl ‘x’ enter (to exit)

Enable the Raspberry Pi server to access the sensors via I2C:

adduser www-data i2c
sudo reboot

Create a new script to display sensor data in the web interface

cd /var/www/html/
sudo nano atmosphere.php

Copy and paste in the following:

 







Ctrl ‘o’ enter (to save)
Ctrl ‘x’ enter (to exit)

Edit the RPi Cam web interface to include the new sensor data script

cd
cd /var/www/html/
sudo nano index.php

Find the second instance of the div and paste in the following just before it:

Ctrl ‘o’ enter (to save)
Ctrl ‘x’ enter (to exit)

You’re done! Reboot your Raspberry Pi, connect to the aerocene-explorer network, point your browser to 172.24.1.1, and (fingers crossed) you should see the web interface of your Aerocene backpack Sensair.