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
- Banana-Pi M2 (or Raspberry-Pi)
- PM sensor: Nova SDS011 PM Sensor with serial to USB interface
- GPS sensor: Ublox-7, Diymall Vk-172 vk 172 Gmouse G-Maus Usb Gps Dongle Glonass
- Debian Linux / Bananian or Armbian or ArchLinux
- Node.js
- Logagent with plugins
- GPS tracking: logagent-gps
- PM measurement: logagent-novasds
- Collect system log files: file input for log file collection
- Share sensor data via MQTT topic: output-mqtt
- Store sensor-data and device logs in Elasticsearch: elasticsearch
- Monitor Logagent/Node.js performance and device metrics: @sematext/logagent-nodejs-monitor
- 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
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:
- 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
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.
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.
apt-get install build-essential
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs
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