ESP8266 Air quality sensor

Everything about esp8266 and more.

Moderator: leecollings

User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: ESP8266 Air quality sensor

Post by sincze »

Aha so mqtt not mandatory?

So works with http.controller out of your box. Nice.
Let's go for a different (aka Jos) approach then.
Tnx.
Shame your solution can not be merged into the main espeasy branch :)
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
RR46
Posts: 7
Joined: Thursday 10 January 2019 12:09
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by RR46 »

I added last week the MHZ-19B sensor to my ESP8266. Before connection the sensor first I flashed ESP Easy to the ESP.

After that I installed:
- DHT22 (including 10K pull-up transistor)
- MHZ-19B

DHT22 works great and gives the correct temperature as also the humidity to Domoticz. But the MHZ-19B sensor don't send any data to Domoticz either in ESP module device...

Image

Firmware ESP8266:
Build:⋄ 20103 - Mega
Libraries:⋄ ESP82xx Core 2_4_2, NONOS SDK 2.2.1(cfd48f3), LWIP: 2.0.3
GIT version:⋄
Plugins:⋄ 76 [Normal] [Testing] [Development]
Build time:⋄ Dec 17 2018 00:15:09
Binary filename:⋄ Self built!

Wiring:
Vin = 5V
Gnd = Gnd
RX = D6
TX = D7

Settings:
Spoiler: show
Image

Image
What's going wrong? :roll: :oops:

I'm looking forward to your support, thanks in advance!
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by jvdz »

Looks like you have both d6 and d7 as input but one is tx and one is tx so guess one needs to be output. What do you see in the espeasy log ?
Also the connection to domoticz will not work with the standard build of espeasy. Just read through this thread on the details.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
RR46
Posts: 7
Joined: Thursday 10 January 2019 12:09
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by RR46 »

I switched D6 (Rx) to input and D7 (Tx) to output (low/high), still no measurements in ESP Easy... also after reboot, strange!


I will look in this topic for data sending to Domoticz. But first I need to get measurements in ESP Easy... :D mayb other firmware flash? Which one would you suggest?
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by jvdz »

So what about the log information?
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
RR46
Posts: 7
Joined: Thursday 10 January 2019 12:09
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by RR46 »

Sorry, forgotten:
1098305: MHZ19: Error, timeout while trying to read
1098305: MHZ19: Unknown response: 0 0 0 0 0 0 0 0 0
1111685: WD : Uptime 19 ConnectFailures 0 FreeMem 14448

Edit 26.03.2019: I found already a topic @ letscontrolit.com...
https://www.letscontrolit.com/forum/vie ... php?t=3857
....Starting version dev-13, this will be supported.....
Where can I check my version? Which build do I need? At the moment I have download a .bin file @ Github. Anyone who has the right .bin file for ESP Easy and sensors I have?
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: ESP8266 Air quality sensor

Post by sincze »

RR46 wrote: Monday 25 March 2019 22:45 Sorry, forgotten:
1098305: MHZ19: Error, timeout while trying to read
1098305: MHZ19: Unknown response: 0 0 0 0 0 0 0 0 0
1111685: WD : Uptime 19 ConnectFailures 0 FreeMem 14448

Edit 26.03.2019: I found already a topic @ letscontrolit.com...
https://www.letscontrolit.com/forum/vie ... php?t=3857
....Starting version dev-13, this will be supported.....
Where can I check my version? Which build do I need? At the moment I have download a .bin file @ Github. Anyone who has the right .bin file for ESP Easy and sensors I have?
jvdz, created his own image :lol: that should work.
I started with the ESPEASY version of last week from the official website., that one worked as well.
However a bit more work needed to get the data in Domoticz as you can see in this forum thread..
btw I did not change anything to input, left it at default.
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: ESP8266 Air quality sensor

Post by EddyG »

Just to show how it can fit in: https://www.eijlander.nl/stekkerbehuizi ... -3703.html
It works fine, except for the random reboot of the espeasy firmware. Most random reboots are within a day.
Housing is 74x43x38 mm.
IMG_20190324_162748+.jpg
IMG_20190324_162748+.jpg (192.73 KiB) Viewed 4021 times
IMG_20190324_162734+.jpg
IMG_20190324_162734+.jpg (192.46 KiB) Viewed 4021 times
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: ESP8266 Air quality sensor

Post by sincze »

This is worth 100 of my daily compliment points. Brilliant. :lol:
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: ESP8266 Air quality sensor

Post by EddyG »

Tnx. It took some effort, but it fits nicely.
Main wires under the pcb and the rest on headers, except some elco's which are under the pcb close to the 5V connection.
Next project will be including a small oled display on the top of the housing.
Current esp8266 connects to Domoticz with PM2,5, PM 10 and systemload.
Prutsium
Posts: 92
Joined: Monday 18 June 2018 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Germany / Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by Prutsium »

EddyG wrote: Tuesday 09 April 2019 20:10 Just to show how it can fit in: https://www.eijlander.nl/stekkerbehuizi ... -3703.html
It works fine, except for the random reboot of the espeasy firmware. Most random reboots are within a day.
Housing is 74x43x38 mm.

IMG_20190324_162748+.jpg
IMG_20190324_162734+.jpg
How do you deal with the temperature? as far as i know the sensor uses it temperature for correction of measurements.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: ESP8266 Air quality sensor

Post by EddyG »

The top part of the housing has ventilation openings in it, for air flow to get the right amount of 'CO2' inside.
It gets warmer inside the housing then the surrounding air.
I do not know exactly what the influence on the reading is.
My lowest reading so far was 398 ppm. According to https://www.co2.earth/ the current reading is almost 412
Highest reading so far 998 ppm. It reacts within 5-10 minutes when somebody enters the room.
So I am almost 3% off, that's not so bad for this instrument. For me it is not exact science.
Unfortunately there is no input for an offset in Domoticz. (would be nice) to get the bottom value up to 412.
I did put everything on headers, so when something dies it is easy exchangable.
B.t.w. according to the sensor it self is the temperature in the housing 34 C, with a livingroom temperature of 20.5 C
janvangent2
Posts: 40
Joined: Thursday 18 October 2018 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: ESP8266 Air quality sensor

Post by janvangent2 »

Hi!

I have the MH-Z19B up and running (in the log file on esp easy I can read the actual ppm and temp value).
However, I don't receive any updates in domoticz.
I'm running domoticz on port 80 (internal) and 443 for external use (https).

When sending the data to domoticz controller using corrent ip/login and IDX number, it always updates the value to 0 ppm.
I also have a DHT22 sensor connected to this ESP8266 unit, and this one properly sending temp/humidity data to the controller.

When the controller option is disabled and I try updating domoticz using the rule method:

on MHZ19#PPM do
SendToHTTP,192.168.1.106,80,/json.htm?param=udevice&type=command&idx=62&nvalue=[MHZ19#PPM]
endon
It is not updating either.

However, when I use my browser to go to:

Code: Select all

http://192.168.1.106/json.htm?param=udevice&type=command&idx=62&nvalue=111.00
It updates without any issues to PPM = 111

Code: Select all

{
   "status" : "OK",
   "title" : "Update Device"
}
What is going on here?

Log:

Code: Select all

3401524: MHZ19: PPM value: 924 Temp/S/U values: 23/0/0.00
3401527: EVENT: MHZ19#PPM=924.00
3401541: ACT : SendToHTTP,192.168.1.106,80,/json.htm?param=udevice&type=command&idx=62&nvalue=924.00
3401550: Command: sendtohttp
3401567: EVENT: MHZ19#Temperature=23.00
3401576: EVENT: MHZ19#U=0.00
janvangent2
Posts: 40
Joined: Thursday 18 October 2018 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: ESP8266 Air quality sensor

Post by janvangent2 »

Edit: when making a "custom sensor" in Domoticz instead of an "Air quality sensor" it is working.

How can I get the same visualisation and good/fair/bad air quality indication for such a custom sensor?
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by jvdz »

You are probably using the standard version of ESPEasy?
If so, you need to add the appropriate rules to ESPEASY as the standard version doesn't have the correct configuration to support Domoticz via API/JSON calls because it is defines as a 3 svalue sensor in stead of a one nvalue sensor.
I have build my own version to support that and other stuff at the time I made it, as the b version wasn't working at that time.
Now all is working except REST for Domoticz.

Example rules are defined in this thread.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
janvangent2
Posts: 40
Joined: Thursday 18 October 2018 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: ESP8266 Air quality sensor

Post by janvangent2 »

jvdz wrote: Tuesday 30 April 2019 16:47 You are probably using the standard version of ESPEasy?
If so, you need to add the appropriate rules to ESPEASY as the standard version doesn't have the correct configuration to support Domoticz via API/JSON calls because it is defines as a 3 svalue sensor in stead of a one nvalue sensor.
I have build my own version to support that and other stuff at the time I made it, as the b version wasn't working at that time.
Now all is working except REST for Domoticz.

Example rules are defined in this thread.

Jos
Hi Jos,

As you see in 2 posts above, I did try 2 ways:

1)
adding the rule:

Code: Select all

on MHZ19#PPM do
SendToHTTP,192.168.1.106,80,/json.htm?param=udevice&type=command&idx=62&nvalue=[MHZ19#PPM]
endon
Which doesn't update domoticz. When I try it manually in browser, it does work/update.
In the log of ESPeasy I can see the "rule" is called, Event --> Act.
So not sure where it goes wrong.

The 2nd option:
2) Using the controlicz controller
--> this works with a custom sensor, but not with air quality as a dummy sensor.

Could you upload your version of ESPeasy somewhere? Because the link to github a couple of pages ago in this thread is no longer active.
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by jvdz »

Ah, I see now..... sorry about that. :D
Could it be you are using Userid/Password security for the Local network preventing the url to update the device?

That second option is what my story was about!

EDIT: there is already a working bin available in this branch: https://github.com/jvanderzande/ESPEasy ... ntv20/dist
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
sincze
Posts: 1299
Joined: Monday 02 June 2014 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands / Breda Area
Contact:

Re: ESP8266 Air quality sensor

Post by sincze »

jvdz wrote: Tuesday 30 April 2019 17:30 Ah, I see now..... sorry about that. :D
Could it be you are using Userid/Password security for the Local network preventing the url to update the device?

That second option is what my story was about!

EDIT: there is already a working bin available in this branch: https://github.com/jvanderzande/ESPEasy ... ntv20/dist
You can use the jvdz solution indeed.

If you want to remain stock.. it is doable. However Rules are NOT working if you need a username and password to update the device as mentioned by jvdz ..

This is also an option ;-)
PPM.JPG
PPM.JPG (28.62 KiB) Viewed 3849 times
Use a custom sensor and airquality meter(idx 21) in combination with some Device LUA logic
Have the ESP update the custom sensor... and the custom sensor the air quality meter...

Code: Select all

commandArray = {}

-- loop through all the changed devices
for deviceName,deviceValue in pairs(devicechanged) do
--    print ("Device based event fired on '"..deviceName.."', value '"..tostring(deviceValue).."'");
    if (deviceName=='PPM_C') then
--        print ("Device value '"..deviceName.."', value '"..tostring(deviceValue).."'");
        devvalue=tostring(deviceValue)
        devidx=21
        commandArray['UpdateDevice']=devidx .. "|" .. devvalue .. "|0"
        os.execute ('curl -s "http://192.168.**.**:8080/json.htm?type=command&param=udevice&idx=1711&nvalue="'..devvalue)
    end
end

return commandArray
Haha in this case I also update a remote domoticz machine with the ' os.execute'.. you can skip that part..
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
janvangent2
Posts: 40
Joined: Thursday 18 October 2018 9:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: ESP8266 Air quality sensor

Post by janvangent2 »

jvdz wrote: Tuesday 30 April 2019 17:30 Ah, I see now..... sorry about that. :D
Could it be you are using Userid/Password security for the Local network preventing the url to update the device?

That second option is what my story was about!

EDIT: there is already a working bin available in this branch: https://github.com/jvanderzande/ESPEasy ... ntv20/dist
OK, flashed this one.
But very strange, it did not overwrite any of the settings of the previous flash. So it immediatly connected to my wifi, and settings of the hardware en controller were already there.
Seems to work now! Thanks

One remark: accessing the espeasy config (so browsing to its IP adres) is much slower compared to the standard latest flash. Any idea what could cause this?
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: ESP8266 Air quality sensor

Post by jvdz »

Nice! :)
The config is stored in EEPROM so it indeed should just work after flashing a new bin, unless they changed the format of the storage.
I have no idea and haven't looked at that code for quite some time now.
Which version did you flash before? This is the V2.0 version of the source, which I used at the time and is now working for quite a while for me.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests