HowTo Setup Sensor and IOT Gateway

Agenda

  • List of Hardware
  • Install SlapOS on Olimex Hardware
  • Configure Envioremental Sensor

 

This tutorial teaches how to setup streaming hardware using 2 Olimex boards.

One board will be connected to the sensor and the second one will serve as an IoT-Gateway.

 

Note :  If the name of the slide starts with '2 *' do the action on both boards.

 

Shopping List

Item
Quantity
Required
2
Yes
1
Yes
2
Yes
Micro SD Card >= 16GB
2
Yes
LAN Switch
1
Yes
LAN Cables
3
Yes
Keyboard
1
Yes
HDMI cable + monitor
1
Yes

 

List of required and recommended hardware. 

Item
Quantity
Required
Wireless Router
1
No
2
No
External USB hub – to split the USB_HOST mounted on the board; you need that to connect more USB devices
1
No
USB-SERIAL-CABLE-F – for Android/Linux debugging on UART0
1
No
CABLE-IDC40-15cm – cable used for LCD_CON ↔ Olimex LCD display
1
No
Adapter cable for the 6-pin VGA connector to standard VGA 15-pin connector
1
No

 

2 * A20-OLinuXino-LIME2

You can order the boards from here.

The first board will be connected to the sensor and the second one will be served as IoT-Gateway. Data from the sensor will be sent to IoT-Gateway and from there to Wendelin. 

Follow instructions in User's Manual to connect to the board and after that follow SlapOS Tutorial - Installing SlapOS Node (Comp-123) to install SlapOS on the boards. Installation process is the same for both boards. 

2 * Prepare microSD Card

Download the latest Debian-based image to both microSD cards.

At the time of writing this tutorial the latest Debian-based image we used is buster.

Using p7zip unzip the downloaded Image


p7zip -d Armbian_5.92.4_Olinuxino-a20_Debian_buster_next_5.2.21.7z

After that  use Etcher or any other software to burn the image to the microSD cards. 

2 * Login to Board

Insert microSD card to in the corresponding slot of the board. 

Connect LAN cable, keyboard and HDMI cable. When all the components are connected plug in the power supply. 

You will be asked to login to system. Use the login and password provided in the documentation of the board. 

At the time of writing this tutorial it is root 1234

If login is successful you will be asked to change the password. 

To check if you are connected to internet do 

ping google.com

2 * Install SlapOS

Follow Tutorial.Install.Slapos.Node.Comp.123 to install SlapOS on the boards.

IoT Gateway is Ready

 

Until this point all the actions were the same for both boards.

As was mentioned before, one board is IoT Gateway and the other one is sensor.

IoT Gateway hardware is prepared.

Next we will describe how to connect the environmental sensor to one of the boards.

Connect MOD_ENV to the Board

 

You can order the sensor from here.

Connect sensor to one of the boards.

Install i2cdetect to find the address of the sensor. 

sudo apt install i2c-tools 

Then use i2cdetect -y [bus number] to find the address of our sensor and the bus. 

Install driver for sensor

pip install bme280

sudo apt-get install python-smbus

read_bme280 --i2c-address 0x77 --i2c-bus 3 

 

Install BME280 Python Driver for the sensor. 

Make sure you have python-smbus python module installed.

Use information from i2cdetect and call read_bme280 command to see the sensor data.

Read Data from Sensor

#!/usr/bin/python
# -*- coding: utf-8 -*-

from bme280 import bme280
from bme280 import bme280_i2c
from bme280.bme280 import read_all
bme280_i2c.set_default_i2c_address(int("0x77", 0))   # address of sensor 0x77
bme280_i2c.set_default_bus(int(3))                              # i2c bus number 3 (i2c-3)
bme280.setup()
data=bme280.read_all()
print("{}\t{}\t{}".format(data.pressure,data.humidity,data.temperature))

Write your own custom_read_bme280.py  script to read data from the sensor and return in desired format.

Store the script in /usr/local/bin/ directory. 

Sensor is Ready