Giter Site home page Giter Site logo

rmh78 / no2-measurement Goto Github PK

View Code? Open in Web Editor NEW
19.0 7.0 4.0 2.25 MB

Arduino project on a ESP32 for NO2 measurement sending the data with LoRaWan to TheThingsNetwork.

C++ 20.67% C 79.33%
no2 temperature humidity air-pressure gps esp32 heltec lorawan air-pollution diesel

no2-measurement's Introduction

Introduction

In this project I built a NO2 measurement station ๐Ÿ˜ท which sends its data via LoRaWan to TheThingsNetwork. A backend nodered server receives the messages and stores them into a MySQL database and then displays all on a dashboard. This project is inspired by the Urban AirQ (http://waag.org/en/project/urban-airq) of the waag society (Results are published here: https://www.atmos-meas-tech-discuss.net/amt-2017-43/). My intention to start this project was to show the amount of NO2 pollution at my home compared to the official measurement station "Landshuter Allee" of my hometown which is one kilometer away.

The NO2 measurement station uses two NO2 sensors, a temperature and humidity sensor, an air-pressure sensor and a GPS module. The sensors are connected with the ESP32 microcontroller which has an OLED display and a LoRa module onboard. All the hardware is powered with a powerbank.

Hardware

  • 1x Heltec ESP32 with LoRa and OLED (http://www.heltec.cn)
  • 1x NO2 sensors from Alphasense (http://www.alphasense.com/index.php/products/nitrogen-dioxide-2)
  • 1x analog/digital converter ADS1115 from Adafruit
  • 1x temperature and humidity sensor SHT31 from Adafruit
  • 1x air-pressure sensor BMP180 from Adafruit
  • 1x GPS module from Adafruit
  • 1x 5V step-up-converter (Pololu reg09b) to power the NO2 sensor
  • 1x Powerbank with 20.000 mAh
  • 1x weatherproofed casing

Image of NO2 measurement station - breadboard Image of NO2 measurement station - testrun

Software-Stack

NodeRed Flow 1 NodeRed Flow 2 Image of NO2 dashboard

Live Dashboard

http://h2708685.stratoserver.net:1880/ui/

Calibration of the NO2 sensor

The NO2 sensors are pre-calibrated and are shipped with a formular to calculate the NO2 concentration in ppb with the measured output voltages of the sensor. Because the results are poor I decided to calibrate the sensors against the measurement data of the official measurement station (http://inters.bayern.de/luebmw/csv/blfu_1404_NO2.csv) of my hometown. I placed my hardware on the roof of my car and placed my car next to the offical station. So I was able to store the measured data of 2 days on the flash memory of the ESP32. With this data I used linear regression (calculate with LibreOffice LINEST function: https://help.libreoffice.org/Calc/Array_Functions#LINEST) to get a linear function which outputs the NO2 concentration in ug/m3 like the official station does. For the linear regression I used the output voltage of NO2 sensor, the temperture, the humidity and the pressure as input data to get the values of the official station.

Image of NO2 calibration - sensor on the parking car Image of NO2 calibration - official station

Power consumption ๐Ÿ”‹

The power consumption is high because the NO2 sensor has an integrated heating that needs to be powered all the time. The sensors, the GPS and the LoRaWan sender drains round about 100mA. That's sad because the device is not a low power device any more. For calibration runs I spent a big powerbank with 20.000 mAh to supply the hardware for some days.

Tasks

  • Software ๐Ÿ’ป
    • build software for offline mode (SD-card instead of LoRaWan)
    • add images to the readme page
  • Testrun (hardware & software) ๐ŸŽˆ
    • 2 day testrun - proof of stability and power consumption --> 01.01.2018 - 02.01.2018 --> successful
    • 7 day testrun - proof of stability --> 13.01.2018 - 19.01.2018 --> successful
  • Calibration ๐Ÿš—
    • 1. calibration run --> 02.01.2018 14:00 - 04.01.2018 - 09:00 --> failed with no data ๐Ÿ˜ข
    • 2. calibration run --> 05.01.2018 12:00 - 07.01.2018 - 15:00 --> after one day no more no2 values (stability-problems with I2C bus)
    • 3. calibration run (to gather data over a wider time-range) --> 22.01.2018 - 28.01.2018 --> GPS did not work all the time, so the date/time was not persisted (recalculated manually)
    • 4. calibration run (direct mount on the official station) --> 06.02.2018 - 13.02.2018 --> again date-time GPS problems I was able to reconstruct the date-time
  • Regression ๐Ÿ“
    • define linear function with multiple linear regression
    • modify nodred flow to use linear function to calculate NO2
  • NodeRed ๐Ÿ“ˆ

Historical conflicts, issues and findings

  • LMIC does not work in with RTOS (https://www.freertos.org) Tasks because of timing issues. There is no current version of the LMIC library for the ESP32. Because of this issue I decided to not use tasks for measurement and sending.
  • LMIC does not work in combination with the SD card reader. I think it's because they are both on the SPI bus. Because of this issue the SD card is only used in the offline mode (used for calibration only).
  • SD card reader does not work very stable. First it does not work with 3.3V as described in the spec. Second it needs exact 5V, so I had to add an additional step-up-converter to power it. My first calibration-run ended with no data on the sd-card. I decided to switch to the internal flash-memory of the ESP32 using SPIFFS (the interface is nearly the same).
  • After some hours running my sensor I'm facing I2C stability problems ([E][esp32-hal-i2c.c:161] i2cWrite(): Busy Timeout!). This is a known issue (espressif/arduino-esp32#834). Trying to reset the I2C wire if temperature measurement results in "not a number".
  • GPS UTC timing issue. Added UTC adjustment in code using the Time.h library.
  • One of my two NO2 sensors does not correlate as expected so I decided to reduce my measurement-station to host only one NO2 sensor. This sensor has now a better posision inside the casing to get more direct air.
  • Prevent the transparent top of the casing with a cardboard to reduce the temperature influence of direct sun exposure.

no2-measurement's People

Contributors

rmh78 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

no2-measurement's Issues

Source of NOx sensor

Howdy,
interesting project. Where did you buy the NOx breakout boards? Your link seems to point only to the bare NO2-A43F sensor, but not to the sensors seen on the picture with the breadboard.
Cheers,
/luetzel

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.