Project: Evaluation of CO2 sensors

some sensors still in calibration phase

In my home automation system I use CO2 sensors from Netatmo and some MH-Z14A based arduino nodes.

I really like, that the Netatmo sensors work for about a year on battery. But they can only be integrated with a cloud api into my home automation. This has led to one interruption of several hours in the past, when the service was down. As I regulate my heating with the measured data of these sensors, this was problematic. 🙂

What I am missing with the battery powered Netatmo sensors, is a led indicating air quality.

To remove the dependency of the cloud api, I decided to build my own sensors. But before I order more MH-Z14A sensors, I want to make an evaluation.

Caution: This article is about the experiences I made in my setup with the sensors I have and with the (maybe buggy) code I wrote. It may be, that you can not reproduce my findings. 🙂

goal:
evaluate CO2 sensors for Netatmo replacement

motivation:

  • I don’t want to be dependent on cloud
  • I wan’t a led indicating air quality with every sensor

deliverables:

  • prototype with every sensor
  • graphs of measurements made with different sensors
  • decision for one sensor

approach:

  • buy samples of different sensors
  • build a prototype with all sensors
  • make measurements, store them in influxdb and make graphs with grafana
  • evaluate the measurements

progress:

  • 20190409
    • Prototype built with MH-Z14A and CCS811
    • API Endpoint with node-red configured to store data in influxdb
    • first dashboard in grafana implemented
    • other sensors ordered
  • Progress 20190424
    • MH-Z19b arrived

findings:

  • na

open items:

  • na

log:

20190410:
The CCS811 seems to reset sometimes (no values for several minutes and then starts with 400ppm). I will add a pull up resistor on the I2C bus.

20180424:
CCS811 is quite complex to handle. It has a MCU and you can make firmware updates. The library from adafruit is incomplete, it doesn’t support baseline-functions, which you have to use. I changed to the sparkfun library.

CCS811 didn’t show usable results in mode 3 (measurement every 60s). Now trying mode 1 (every 1s) with a moving average over one minute.

MH-Z19b arrived

improved cheap ntp stratum 1 server

The cheap stratum ntp server based on ESP8266 turned out as unstable. I’m not sure, if it is a hardware or a software problem.  The module suddenly hangs and then sometimes the watchdog is triggering and sometimes only a poweroff and poweronn will get the wifi connection up again. I had similar problems with my secure esp8266 sensor node. It seems, that the problems are more often with many data transmitted via serial interface.

I have adapted my arduino code to be used with an ESP32 and made a prototype with this platform. Time will show, if this solves all the stability problems.

 

 

using ntp on my qnap nas with my self made stratum 1 server

Playing with my new ntp stratum 1 server I had to dig deeper into configurations of different devices. Most of them have a simple possibility to add some ntp servers but they don’t offer advanced parameters. Under the hood I found often a standard ntpd implementation with an ntp.conf file. And that implementation would offer so many features you can’t activate with the offered web-interface. Examples here are EdgerouterLite, QNAP NAS and VMWARE ESXi.

On the qnap nas you first set time sync to manual. Then you configure the ntp server in the webui. Here you can’t add a sync source. WTF!

You can edit the ntp configuration with

Here is my configuration:

You can stop ntpd

Check if it has stopped

You can start it with

You can then test the setup with:

Be prepared to do these modifications after firmware upgrades or if you change settings in the QNAP admin UI.

building a cheap stratum 1 gps ntp timeserver

goal:
have a reliable local ntp timesource

motivation:

  • be independant of a internet connection
  • study the possibilities of cheap GPS devices

deliverables:

  • running ntp timeserver with GPS time
  • source code for ESP8266 for arduino IDE

approach:

  • find a ebook with code samples
  • play with the technology
  • implement
  • test

notes:

Progress

  • GPS sync for local clock implemented, setting local clock fails on some devices
  • ntp server prototype without GPS implemented
  • Do not use the standard softwareserial library with wifi, as it may crash the system. Use espsoftwareserial instead. I had to pay hard to find out…
  • Code is working now:

findings:

  • the esp9266 has a high resolution clock, but I can not set it on all devices
  • a PPS signal on the GPS device is the key to a high precision time source
  • atom with platformio ide is a nice development environment

open items:

  • build a nice 3d printed enclosure

source code:

 

secure esp8266 sensor node

Some of my sensors use mqtt to publish their data to a mosquitto mqtt server. To have a really secure configuration I should:

  • use ssl/tls as transport
  • use authentication with one user / device
  • restrict topics to those users

Thinking about all the work that is involved for doing this, following idea came up:

  • use a REST service with https (with node-red)
  • to prevent replay attacks, add a timestamp to the message
  • sign the messages with an individual AES-Key

Here is a POC arduino sketch: