Code Monkey home page Code Monkey logo

airpollutiontracker's Introduction

Air pollution tracker

DIY IoT project for mobile air-pollution measurements and real-time analysis. Read my blog post for more details.

  • Mobile device collecting PM10, PM2.5 sensor data with GPS coordinates
  • Publishing air pollution data via MQTT
  • Storing sensor data as time series with GPS coordinates in Elasticsearch or Sematext Cloud
  • Node.js software for data collection with low memory and CPU footprint (<50 MB RAM, <2% CPU)
  • Device monitoring and log file collection for troubleshooting
  • Visualization
  • Alerts

Table of Contents

Architecture

Hardware

Software

On the device

In the Cloud

  • MQTT Broker mosquitto
  • Elasticsearch or Sematext Cloud Create in Sematext Cloud two logging apps. One for linux logs and one for sensor data. If you like to monitor the Node.js and device performance create a Node.js monitoring app. Dashboards and alerts can be managed in Sematext Cloud. Kibana is integrated. Alternative dashboard tools like Grafana could be used with the Elasticsearch data source for Sematext Cloud.

Kibana dashboard (integrated in Sematext Cloud UI)

Grafana Dashboard using data from Sematext Cloud / Elasticsearch API

On your desktop

  • IoT platforms with MQTT support: Node-Red or Octoblu
  • Web browser
  • SSH terminal

Banana-Pi setup

Wi-Fi setup

A smart phone will serve as mobile Wi-Fi hotspot.
Enable internet tethering (iPhone hotspot) on your mobile phone.

Insert WLAN USB device (if your device has no WLAN chip) Then configure Banana-Pi wlan interface:

  1. Use the WPA passphrase to calculate the correct WPA PSK hash for your SSID (Wi-Fi Network name) by altering the following example
apt-get install wpasupplicant

wpa_passphrase my-mobile-phone-hotspot-name my_very_secret_passphrase

network={
        ssid="myssid"
        #psk="my_very_secret_passphrase"
        psk=ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b
}

Then edit /etc/network/interfaces and enter your WLAN SSID and PSK:

auto wlan0
iface wlan0 inet dhcp
        wpa-ssid myssid
        wpa-psk ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b

Restart the wlan0 interface:

ifdown wlan0 && ifup wlan0

Nova SDS011 setup

Insert the Nova-SDS011 USB connector. Then search for new Ttty devices.

ls -l /dev/tty* | grep 'dialout'
# /dev/ttyUSB0

Note the name for the `input.novaSDS011.comPort setting in the Logagent configuration file.

GPS sensor setup

Insert the USB GPS dongle. Then search for new Ttty devices.

ls -l /dev/tty* | grep 'dialout'
# /dev/ttyACM0

Note the name input.gps.comPort setting in the Logagent configuration file.

Install Node.js

apt-get install build-essential
curl -sL https://deb.nodesource.com/setup_8.x | bash - 
apt-get install -y nodejs

Install Logagent

Install @sematext/logagent and relevant plugins

npm i -g --unsafe-perm @sematext/logagent 
npm i -g --unsafe-perm logagent-gps logagent-novasds
npm i -g --unsafe-perm @sematext/logagent-nodejs-monitor 

Create a system service and default configuration file '/etc/sematext/logagent.conf':

logagent-setup -t indexName -e http://localhost:9200  
service logagent stop

Adjust the Logagent configuration and check following settings:

  • input.novaSDS011.comPort
  • input.gps.comPort
  • input.nodejsMonitor.SPM_TOKEN
  • output.mqtt.url
  • output.elasticsearch.url
  • output.elasticsearch.indices

Test the configuration with

logagent --config logagent.yml 

Copy the working configuration file logagent-config.yml to /etc/sematext/logagent.conf and start the service with

service logagent start 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.