ESP8266 Air quality sensor

Everything about esp8266 and more.
User avatar
jvdz
Posts: 1423
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by jvdz » Sunday 29 October 2017 15:39

I am running an Wemos D1 + MH-Z19b since a few months now with a modified version of ESPEASY I made as described here: https://gathering.tweakers.net/forum/li ... 9#52624079
This Wemos also has 2 LUX sensors, a DHT22 Sensor for Temp&Humidity and a BMP180 Barometer (Presure).
All these devices are directly updated via the build in options of this modified ESPEASY version by a URL call.
The devices are all setup in Dummy hardware which you first need to create yourself and then use the IDX in the ESPEASY definition for the device:
Knipsel.PNG
Knipsel.PNG (40.11 KiB) Viewed 3431 times
The graph created by the MH-Z19b/CO-20 looks like this:
Knipselb.PNG
Knipselb.PNG (246.72 KiB) Viewed 3431 times
The thread I linked is a good place to find some information about the usage of this setup.

Jos

User avatar
LouiS22
Posts: 494
Joined: Friday 27 February 2015 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: Budapest, Hungary
Contact:

Re: ESP8266 Air quality sensor

Post by LouiS22 » Sunday 29 October 2017 16:23

Topcase1 wrote:
Sunday 29 October 2017 15:23
Because I'm new here I say Hello to everyone,

The air quality sensor made of an ESP8266 and an MH-Z19 is true to me.
What I understand is that you can use and pair this combination of stand alone with Wi-Fi to my Raspberrypi on which Domoticz stands?
Now I saw the print of a CO2 chart, and I want that too.
But on the same print, I see hardware as the Volcraft co-20 in Domoticz.
Can anyone explain how this is? Is it that if you download the software by itself, if you have Volcraft in Domoticz?

Thanks in advance,

Topcase1
You have to create a dummy sensor in Domoticz, then create a CO2 virtual sensor within. Note its IDX, that's what you have to feed from ESP8266 (for example Espeasy).

Topcase1
Posts: 3
Joined: Sunday 29 October 2017 14:47
Target OS: Raspberry Pi
Domoticz version: v3.8153
Location: Maassluis, Zuid-Holland
Contact:

Re: ESP8266 Air quality sensor

Post by Topcase1 » Sunday 29 October 2017 19:33

Jos en LouiS22, Thanks!

Topcase1

nixalsschrott
Posts: 39
Joined: Tuesday 11 July 2017 10:26
Target OS: NAS (Synology & others)
Domoticz version: beta
Location: Germany
Contact:

Re: ESP8266 Air quality sensor

Post by nixalsschrott » Friday 03 November 2017 17:27

jvdz wrote:
Sunday 29 October 2017 15:39
I am running an Wemos D1 + MH-Z19b since a few months now with a modified version of ESPEASY I made as described here: https://gathering.tweakers.net/forum/li ... 9#52624079
.....
It sounds very interesting and is also very close to what I am searching for.
Since your link does not contain english or german description it would be very helpful, if you could provide a little howto with component list and steps to set up the hard- and firmware.

Kind regards
matty
Domoticz Beta v3.9317 for DSM 6.1 | Aeon Labs Z-Wave USB Stick | Cyrus SmartHome 4-in-1 Multisensor | Qubino ZMNHCD1 - Roller Shutter | NEO COOLCAM NAS-WR01ZE Power Plug | WEMOS D1 MINI (ESP8266) Sensors CO2/TEMP/BARO | Denon AVR

User avatar
jvdz
Posts: 1423
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by jvdz » Friday 03 November 2017 18:27

Hi Matty,

No problem. We can do that here so others can also benefit from it... and maybe later convert that into a Wiki page once we have nailed down the appropriate process.
So lets start simple and work our way into the details depending on how far you are already.
Components used:
  • Wemos D1 mini - https://wiki.wemos.cc/products:d1:d1_mini
  • MH-Z19(b) (Either A or B version will work. I have a B version)
  • ESPEasy - Latest Mega version will work but won't update via HTTP JSON with the standard settings. My version does work with JSON. So the below only works with my GIT version at this moment.
Assembling
Connect the following:
MH-Z19 Tx → Wemos pin D5
MH-Z19 Rx → Wemos pin D6
MH-Z19 gnd → Wemos gnd pin
MH-Z19 vin → Wemos 5V pin (Only for MHZ19B, else 3.3V if I remember correctly!)

Loading ESPEASY
Either I can provide the bin to load or you can build it yourself by setting up the following:Source code development
Load the Bin file either from Atom or the load process describe here.


Add Airquality device to Domoticz:
Goto the Domoticz webpage and select: Setup/Hardware.
Add A dummy Sensor:
air0a.PNG
air0a.PNG (57.06 KiB) Viewed 3375 times
air0b.PNG
air0b.PNG (11.07 KiB) Viewed 3375 times
Make a note of the created device IDX found in in Setup/Devices
air0c.PNG
air0c.PNG (52.83 KiB) Viewed 3375 times
Continue Next post (can only attach 3 images each post)
Last edited by jvdz on Monday 05 February 2018 21:28, edited 5 times in total.

User avatar
jvdz
Posts: 1423
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by jvdz » Friday 03 November 2017 18:27

Configuring ESPEasy:
Goto the webpage of the Wemos/ESPEasy unit and do de basic configuration as described in this page.
Define the Domoticz server under the controllers Tab:
AIR1.PNG
AIR1.PNG (30.02 KiB) Viewed 3374 times
and fill in the appropriate information to connect to your Domoticz server.
Define the Device is the Devices tab:
air2.PNG
air2.PNG (49.95 KiB) Viewed 3374 times
.. and fil in the field as shown and use the Found IDX of the domoticz device in the "Send to controller IDX field.

You should be in business after you saved this.
Under the Tools/LOG option in ESPEASY you find information about the steps ESPEASY does and when it receives information.
This is the log I have and you see also the MHZ19 in there:
air3.PNG
air3.PNG (64.13 KiB) Viewed 3374 times
Shoot when you have questions.
Jos

nixalsschrott
Posts: 39
Joined: Tuesday 11 July 2017 10:26
Target OS: NAS (Synology & others)
Domoticz version: beta
Location: Germany
Contact:

Re: ESP8266 Air quality sensor

Post by nixalsschrott » Monday 06 November 2017 10:31

Dear Jos,

really fast reply - thanks a lot.
I need some time to proceed since I am going to order the parts from China, delivery will need approximitely at least 2 weeks.

Regarding the component list you also mentioned DHT22 and GY-68 BMP180 before. Do these sensors also work within this project (connect to same PCB)? Then I would add this parts to my order.

Kind regards
matty
Domoticz Beta v3.9317 for DSM 6.1 | Aeon Labs Z-Wave USB Stick | Cyrus SmartHome 4-in-1 Multisensor | Qubino ZMNHCD1 - Roller Shutter | NEO COOLCAM NAS-WR01ZE Power Plug | WEMOS D1 MINI (ESP8266) Sensors CO2/TEMP/BARO | Denon AVR

User avatar
jvdz
Posts: 1423
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by jvdz » Monday 06 November 2017 10:59

Yes they do. I've also made some changes in my port of the ESPEASY software to support direct update of the of the dummy BMP180 sensor in Domoticz using the standard HTTP config with IDX.

Jos

User avatar
LouiS22
Posts: 494
Joined: Friday 27 February 2015 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: Budapest, Hungary
Contact:

Re: ESP8266 Air quality sensor

Post by LouiS22 » Monday 06 November 2017 11:39

jvdz wrote:
Friday 03 November 2017 18:27

[*]ESPEasy - Latest Mega version will work but won't update via HTTP JSON with the standard settings.
Actually it works, you have to define a rule, then it's ok. Of course your solution is much more elegant ;)

One question though: have you noticed any "not stable reading" error messages? I have it from time to time.

User avatar
jvdz
Posts: 1423
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by jvdz » Monday 06 November 2017 14:39

LouiS22 wrote:
Monday 06 November 2017 11:39
jvdz wrote:
Friday 03 November 2017 18:27

[*]ESPEasy - Latest Mega version will work but won't update via HTTP JSON with the standard settings.
Actually it works, you have to define a rule, then it's ok. Of course your solution is much more elegant ;)
Correct, hence my comment that it doesn't work with the standard settings for IDX and Domoticz host. ;)
LouiS22 wrote:
Monday 06 November 2017 11:39
One question though: have you noticed any "not stable reading" error messages? I have it from time to time.
That won't happen on my setup as I have a mh-z19b version, which doesn't supply the S value, so that is set to 0.
That actually was the reason I made my own version of ESPEASY, since the standard version at the time would always come back with that warning and others had the same issue with the b variant.

Jos

User avatar
LouiS22
Posts: 494
Joined: Friday 27 February 2015 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: Budapest, Hungary
Contact:

Re: ESP8266 Air quality sensor

Post by LouiS22 » Monday 06 November 2017 15:30

jvdz wrote:
Monday 06 November 2017 14:39
LouiS22 wrote:
Monday 06 November 2017 11:39
jvdz wrote:
Friday 03 November 2017 18:27

[*]ESPEasy - Latest Mega version will work but won't update via HTTP JSON with the standard settings.
Actually it works, you have to define a rule, then it's ok. Of course your solution is much more elegant ;)
Correct, hence my comment that it doesn't work with the standard settings for IDX and Domoticz host. ;)
LouiS22 wrote:
Monday 06 November 2017 11:39
One question though: have you noticed any "not stable reading" error messages? I have it from time to time.
That won't happen on my setup as I have a mh-z19b version, which doesn't supply the S value, so that is set to 0.
That actually was the reason I made my own version of ESPEASY, since the standard version at the time would always come back with that warning and others had the same issue with the b variant.

Jos
Never noticed there's a B variant (mine is without B - and that's also producing the error message).

User avatar
jvdz
Posts: 1423
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by jvdz » Monday 06 November 2017 18:19

You can check the value of S when you check the ESPEASY values for the device.
Anything below 64 is considered "unstable" in the ESPEASY software for the A version, and will trigger this message.
TD-er made several changes lately for the standard version of ESPEASY in which this piece of code does the checking for S. It nicely explains the usage of it with the also included delay filter option:

Code: Select all

if (s > 0 && s < 64 && filterValue != PLUGIN_049_FILTER_OFF) {
    // Not the "B" version of the sensor, S value is used.
    // S==0 => "B" version, else "A" version
    // The S value is an indication of the stability of the reading.
    // S == 64 represents a stable reading and any lower value indicates (unusual) fast change.
    // Now we increase the delay filter for low values of S and increase response time when the
    // value is more stable.
    // This will make the reading useful in more turbulent environments,
    // where the sensor would report more rapid change of measured values.
    difference = difference * s;
    difference /= 64;
    log += F("Compensate Unstable ");
    filterApplied = true;
  }
This code is executed when the delay filter is off and is the old behavior:

Code: Select all

case PLUGIN_049_FILTER_OFF: {
      if (s != 0 && s != 64) {
        log += F("Skip Unstable ");
        return false;
      }
      filterApplied = false;
      break;
    }
I am not using this version so have no real experience with it, but can only say that the B version I have seems to be pretty stable in its readings.

Jos

User avatar
LouiS22
Posts: 494
Joined: Friday 27 February 2015 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: Budapest, Hungary
Contact:

Re: ESP8266 Air quality sensor

Post by LouiS22 » Tuesday 07 November 2017 11:17

jvdz wrote:
Monday 06 November 2017 18:19
You can check the value of S when you check the ESPEASY values for the device.
Anything below 64 is considered "unstable" in the ESPEASY software for the A version, and will trigger this message.
TD-er made several changes lately for the standard version of ESPEASY in which this piece of code does the checking for S. It nicely explains the usage of it with the also included delay filter option:

Code: Select all

if (s > 0 && s < 64 && filterValue != PLUGIN_049_FILTER_OFF) {
    // Not the "B" version of the sensor, S value is used.
    // S==0 => "B" version, else "A" version
    // The S value is an indication of the stability of the reading.
    // S == 64 represents a stable reading and any lower value indicates (unusual) fast change.
    // Now we increase the delay filter for low values of S and increase response time when the
    // value is more stable.
    // This will make the reading useful in more turbulent environments,
    // where the sensor would report more rapid change of measured values.
    difference = difference * s;
    difference /= 64;
    log += F("Compensate Unstable ");
    filterApplied = true;
  }
This code is executed when the delay filter is off and is the old behavior:

Code: Select all

case PLUGIN_049_FILTER_OFF: {
      if (s != 0 && s != 64) {
        log += F("Skip Unstable ");
        return false;
      }
      filterApplied = false;
      break;
    }
I am not using this version so have no real experience with it, but can only say that the B version I have seems to be pretty stable in its readings.

Jos
Thanks, I did a custom build from github yesterday evening with the latest modifications - will see how it performs. There's indeed new options to customize ZH19 behaviour - even for the "old" version.

User avatar
Igrek
Posts: 10
Joined: Sunday 22 October 2017 11:28
Target OS: NAS (Synology & others)
Domoticz version: 3.8153
Location: Moscow
Contact:

Re: ESP8266 Air quality sensor

Post by Igrek » Tuesday 07 November 2017 13:50

Thanks, I did a custom build from github yesterday evening with the latest modifications - will see how it performs.
Hello!
This plug-in gives out three values, the dummy Sensor Co2 does not accept such. :?
Which Domoticz sensor did you use?

User avatar
LouiS22
Posts: 494
Joined: Friday 27 February 2015 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: Budapest, Hungary
Contact:

Re: ESP8266 Air quality sensor

Post by LouiS22 » Tuesday 07 November 2017 14:14

Igrek wrote:
Tuesday 07 November 2017 13:50
Thanks, I did a custom build from github yesterday evening with the latest modifications - will see how it performs.
Hello!
This plug-in gives out three values, the dummy Sensor Co2 does not accept such. :?
Which Domoticz sensor did you use?
Dummy CO2, but I'm using it with a rule created within ESPEasy (http push into Domoticz). Let me know if you need it. BTW I only use the PPM value.
Last edited by LouiS22 on Tuesday 07 November 2017 15:22, edited 1 time in total.

User avatar
Igrek
Posts: 10
Joined: Sunday 22 October 2017 11:28
Target OS: NAS (Synology & others)
Domoticz version: 3.8153
Location: Moscow
Contact:

Re: ESP8266 Air quality sensor

Post by Igrek » Tuesday 07 November 2017 14:42

LouiS22 wrote:
Tuesday 07 November 2017 14:14
Dummy CO2, but I'm using it with a rule created within ESPEasy (JSON and push the value into Domoticz). Let me know if you need it. BTW I only use the PPM value.
Yes, I also need only PPM value!
Now I receive the text and run parse the LUA script.
Sure that there is a way easier... :)
I need it!
Ta!

User avatar
jvdz
Posts: 1423
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by jvdz » Tuesday 07 November 2017 19:07

Just enable the Rules in ESPEasy and add this rule:
Where:
<MHZ19> = Devicename of the MHZ19 unit in ESPEASY
<DomoticsIP> = IP address of your domoticz server
<port> = port used by your domoticz server
<IDX> = The IDX of the device in Domoticz

Code: Select all

on <MHZ19>#PPM do
  SendToHTTP,<DomoticsIP>,<port>,/json.htm?type=command&param=udevice&idx=<IDX>&nvalue=[MHZ19#PPM]
endon
The rule will be started each time an new value arrives and prerform the url.

Jos

User avatar
LouiS22
Posts: 494
Joined: Friday 27 February 2015 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: Budapest, Hungary
Contact:

Re: ESP8266 Air quality sensor

Post by LouiS22 » Tuesday 07 November 2017 19:24

jvdz wrote:
Tuesday 07 November 2017 19:07
Just enable the Rules in ESPEasy and add this rule:
Where:
<MHZ19> = Devicename of the MHZ19 unit in ESPEASY
<DomoticsIP> = IP address of your domoticz server
<port> = port used by your domoticz server
<IDX> = The IDX of the device in Domoticz

Code: Select all

on <MHZ19>#PPM do
  SendToHTTP,<DomoticsIP>,<port>,/json.htm?type=command&param=udevice&idx=<IDX>&nvalue=[MHZ19#PPM]
endon
The rule will be started each time an new value arrives and prerform the url.

Jos
Indeed, with the below correction: udevice goes first, then type!

Code: Select all

on CO2TEST#PPM do
   SendToHTTP 192.168.0.19,8080,/json.htm?param=udevice&type=command&idx=2894&nvalue=[CO2TEST#PPM]
endon
(my device name is CO2TEST, you can replace it with the one you like)

User avatar
jvdz
Posts: 1423
Joined: Tuesday 30 December 2014 20:25
Target OS: Raspberry Pi
Domoticz version: Stable
Location: Westland/Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by jvdz » Tuesday 07 November 2017 19:45

Pretty sure it worked that way before I changed my ESPEASY version, which is to be expected. ;)

Thelion
Posts: 46
Joined: Saturday 08 October 2016 12:15
Target OS: Raspberry Pi
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by Thelion » Tuesday 07 November 2017 19:51

Hi,

I'm following this topic and I'm about to order the components, but I noticed there is a 0-2000PPM and a 0-5000PPM version of the MH-Z19B

I really hope the air quality never gets in the 5000PPM range, but more range is better, right?

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests