Join our Discord Server
Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 570+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 8900+ members and discord server close to 2200+ members. You can follow him on Twitter(@ajeetsraina).

Sensor Data Collection and Analytics – From IoT to Cloud in 5 Minutes

3 min read

The BME680 is a digital 4-in-1 sensor with gas, humidity, pressure, and temperature measurement based on proven sensing principles. The state-of-the-art BME680 breakout lets you measure temperature, pressure, humidity, and indoor air quality, and is Raspberry Pi and Arduino-compatible!

The sensor module is housed in an extremely compact metal-lid LGA package with a footprint of only 3.0 × 3.0 mm² with a maximum height of 1.00 mm (0.93 ± 0.07 mm). Its small dimensions and its low power consumption enable the integration in battery-powered or frequency-coupled devices, such as handsets or wearables.

Typical applications

You can use this breakout to monitor every aspect of your indoor environment. Its gas resistance readings will react to changes in volatile organic compounds and can be combined with humidity readings to give a measure of indoor air quality. Here are the list of typical applications:


– Indoor air quality
– Home automation and control
– Internet of things
– Weather forecast
– GPS enhancement (e.g. time-to-first-fix improvement, dead reckoning, slope detection)
– Indoor navigation (change of floor detection, elevator detection)
– Outdoor navigation, leisure and sports applications
– Vertical velocity indication (rise/sink speed)

Features

  • Measuring temperature, pressure, humidity, air quality sensor
  • I2C interface, with address select via ADDR solder bridge (0x76 or 0x77)
  • 3.3V or 5V compatible
  • Reverse polarity protection
  • Raspberry Pi-compatible pinout (pins 1, 3, 5, 7, 9)
  • Compatible with all models of Raspberry Pi, and Arduino
  • Python library
  • Datasheet

Let us see how to fetch sensor data from BME680 on the NVIDIA Jetson Nano board and send it to the Cloud Platform.

Hardware requirements:

  • Jetson Nano: 2GB Model ($59)
  • A 5V 4Amp charger
  • 128GB SD card
  • BME680 sensors

Software requirements:

  • Jetson SD card image from NVIDIA
  • Etcher software installed on your system

You can run RedisTimeSeries directly over an IoT Edge device. Follow the below steps to build RedisTimeSeries Docker Image over Jetson Nano:

Verifying Docker version

SSH to your Jetson Nano board equipped with BME680 sensor and install Docker

pico@pico1:~$ docker version
Client: Docker Engine - Community
 Version:           20.10.3
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        48d30b5
 Built:             Fri Jan 29 14:33:34 2021
 OS/Arch:           linux/arm64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:43:42 2021
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.4.3
  GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b
 nvidia:
  Version:          1.0.0-rc92
  GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Verifying if Sensor is detected

i2cdetect -r -y 1
    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- --

Building Docker Image for RedisTimeSeries for Jetson Nano

git clone --recursive https://github.com/RedisTimeSeries/RedisTimeSeries.git
cd RedisTimeSeries.git
docker build -t ajeetraina/redistimeseries-jetson . -f Dockerfile.jetson.edge

Running RedisTimeSeries

docker run -dit -p 6379:6379 ajeetraina/redistimeseries-jetson

Verifying if RedisTimeSeries Module is loaded

redis-cli
127.0.0.1:6379> info modules
# Modules
module:name=timeseries,ver=999999,api=1,filters=0,usedby=[],using=[],options=[]
127.0.0.1:6379>

Clone the repository

$ git clone https://github.com/redis-developer/redis-datasets
$ cd redis-datasets/redistimeseries/realtime-sensor-jetson

Running Sensorload Script

sudo python3 sensorloader2.py --host localhost --port 6379

Running Grafana on Jetson Nano

docker run -d -e "GF_INSTALL_PLUGINS=redis-app" -p 3000:3000 grafana/grafana

There you go..

Point your browser to https://:3000. Use “admin” as username and password to log in to the Grafana dashboard.

image

Click the Data Sources option on the left side of the Grafana dashboard to add a data source.

image

Under the Add data source option, search for Redis and the Redis data source will appear as shown below:

image
image

Supply the name, Redis Enterprise Cloud database endpoint, and password, then click Save & Test.

Click Dashboards to import Redis and Redis Streaming. Click Import for both these options.

image

Click on Redis to see a fancy Grafana dashboard that shows the Redis database information:

image
image

Finally, let’s create a sensor dashboard that shows temperature, pressure, and humidity. To start with temperature, first click on + on the left navigation window. Under Create option, Select Dashboard and click on the Add new panel button.

image

A new window will open showing the Query section. Select SensorT from the drop-down menu, choose RedisTimeSeries as type, TS.GET as command and ts”temperature as key.

image

Choose TS.GET as a command.

image

Type ts”temperature as the key.

image

Click Run followed by Save, as shown below:

image

Now you can save the dashboard by your preferred name:

image

Click Save. This will open up a sensor dashboard. You can click on Panel Title and select Edit.

image

Type Temperature and choose Gauge under Visualization.

image

Click Apply and you should be able to see the temperature dashboard as shown here:

image

Follow the same process for pressure (ts:pressure) and humidity (ts:humidity), and add them to the dashboard. You should be able to see the complete dashboard readings for temperature, humidity, and pressure. Looks amazing. Isn’t it?

References

Have Queries? Join https://launchpass.com/collabnix

Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 570+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 8900+ members and discord server close to 2200+ members. You can follow him on Twitter(@ajeetsraina).
Join our Discord Server
Index