Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CO2 MH-Zxx #1248

Closed
wants to merge 3 commits into from
Closed

CO2 MH-Zxx #1248

wants to merge 3 commits into from

Conversation

bashlikova
Copy link

add CO2 MH-Zxx sensor support

add CO2 MH-Zxx sensor support
@servim
Copy link

servim commented Nov 26, 2017

I support! This sensor is not enough.

@Shmigger
Copy link

I look forward to these changes, too!

@servim
Copy link

servim commented Dec 4, 2017

Tell me, I can not understand if this sensor will be supported or not. I understand English very poorly and I am not familiar with the work of the github. Here I see that they did support, but there is no firmware in it, why?
Thank you!

@Shmigger
Copy link

Shmigger commented Dec 4, 2017

@servim what kind of Sonoff device do you use?

@servim
Copy link

servim commented Dec 4, 2017

with CO2 sensor I want to use Wemos D1 mini

@bashlikova
Copy link
Author

but there is no firmware in it, why?
You can find firmware (bin) in fork repository.
https://github.com/bashlikova/Sonoff-Tasmota/tree/development/bin

MH-Zxx sensor uses UART connection (Rx, Tx, GND) and need +5 Vcc

In configuration select sensor for GPIO 1 (Tx) or GPIO 3 (Rx) - there is no difference

image

image

@servim
Copy link

servim commented Dec 4, 2017

thanks It works!
I have a temperature too 63 * C, a suspicious resemblance :)

@Shmigger
Copy link

Shmigger commented Dec 4, 2017

@servim What kind of CO2 sensor do you use?

@arendst
Copy link
Owner

arendst commented Dec 4, 2017

I'm working on a supported implementation but have to wait for my MH-Z19B to arrive so hold on...

@Shmigger
Copy link

Shmigger commented Dec 4, 2017

@arendst Active woking on CO2 support is the best way to transfer this to main brach of Tasmota :)

@servim
Copy link

servim commented Dec 4, 2017

What kind of CO2 sensor do you use?

MH-Z19

arendst added a commit that referenced this pull request Dec 4, 2017
Add (experimental) support for sensor MH-Z19(B) to be enabled with
define USE_MHZ19 in user_config.h (#561, #1248)
@arendst
Copy link
Owner

arendst commented Dec 4, 2017

Just released MH-Z19(B) support. Currently only supported on hardware serial interface due to lack of iram.

Please test and let me know your results.

image

image

@bashlikova
Copy link
Author

It doesn't work with my MH-Z14
image
image

@servim
Copy link

servim commented Dec 5, 2017

Thank you, MH-Z19 is working! The temperature is like the real one.
MH-Z14 I have removed, how to get to it, I'll try, I'll tell!
PS: IMHO temperature is not needed (saving memory), I think it has an error, because the sensor in the interior of the housing is located and is most likely used to adjust the readings of co2
PPS: I have another CO2 sensor,
download

the results are very different 100-150 ppm, I'll observe.

@bashlikova
Copy link
Author

PPS: I have another CO2 sensor,
the results are very different 100-150 ppm, I'll observe.

Yes, I compare with the same sensor.
MH-Z usually gives values ​​of 100-200 lower. And MHZ is faster.

@ionciubotaru
Copy link

Adding MH-Z19 to Tasmota is a great improvement. There is also BME680 - it will be nice to add it -#1212

arendst added a commit that referenced this pull request Dec 5, 2017
Add experimental support for sensor MH-Z19(B) using SoftwareSerial to be
enabled with define USE_MHZ19 in user_config.h (#561, #1248)
@arendst
Copy link
Owner

arendst commented Dec 5, 2017

The current SoftwareSerial library uses too much iram and causes compilation to fail.

I just released a patched version of the SoftwareSerialNoIram library to be used with a second version of the MH-Z19(B) driver.

@servim Can you please verify if this combinations also works for the MH-Z19 allowing to select more different GPIOs.

@servim
Copy link

servim commented Dec 6, 2017

My English is very bad, I can not tell, watch the video.
https://youtu.be/TgDa1yJjDe0

@arendst
Copy link
Owner

arendst commented Dec 6, 2017

Ah. Thnx. That makes sense. It happens because the interrupts have to be services by rom instead of iram and that takes time to service leading to missed interrupts.

I have to reconsider how to fix or conceal this.

@servim
Copy link

servim commented Dec 6, 2017

OK! I am ready to check at any time. I have mh-z14, but it is far away when I'm there, I can also check it.

@arendst
Copy link
Owner

arendst commented Dec 6, 2017

Just a remark. Did you try on different GPIOs than the default hardware serial GPIOs? If not than your video is expected as the hardware serial interferes with the software serial.

In that case please select different GPIOs and do not use GPIO1 and GPIO3:

image

@servim
Copy link

servim commented Dec 6, 2017

the video shows that I used gpio4 and gpio5 - (look at 1:05)

@servim
Copy link

servim commented Dec 6, 2017

flooded the firmware in mh-z14, there is no result :(

arendst added a commit that referenced this pull request Dec 6, 2017
5.10.0a
 * Add (experimental) support for sensor SHT3x
 * Add support
for sensor MH-Z19(B) using serial interface to be enabled with define
USE_MHZ19 in user_config.h (#561, #1248)
 * Add (experimental) support
for sensor MH-Z19(B) using SoftwareSerial to be enabled with define
USE_MHZ19 in user_config.h (#561, #1248)
 * Add support for iTead SI7021
temperature and humidity sensor by consolidating DHT22 into AM2301 and
using former DHT22 as SI7021 (#735)
 * Fix BME280 calculation (#1051)
 *
Add support for BME680 using adafruit libraries (#1212)
 * Change
ADS1115 default voltage range from +/-2V to +/-6V (#1289)
 * Add
multipress support and more user configurable options to Sonoff Dual R2
(#1291)
 * Fix Sonoff Bridge missed learned key if learned data contains
0x55 (End of Transmission) flag (#1095, #1294)
 * Add support for
TSL2561 using adafruit library (#661, #1311)
 * Add alternative support
for SHT3x (#1314)
arendst added a commit that referenced this pull request Dec 6, 2017
Add iram option to MHZ19(B) driver (#1248)
@arendst
Copy link
Owner

arendst commented Dec 6, 2017

Made some changes to allow Standard SoftwareSerial test.

Pls try to test again with the following changes in user_config.h:

//#define USE_WS2812                               // WS2812 Led string using library NeoPixelBus (+5k code, +1k mem) - Disable by //
  #define USE_WS2812_CTYPE     1                 // WS2812 Color type (0 - RGB, 1 - GRB, 2 - RGBW, 3 - GRBW)
//  #define USE_WS2812_DMA                         // DMA supports only GPIO03 (= Serial RXD) (+1k mem). When USE_WS2812_DMA is enabled expect Exceptions on Pow

//#define USE_MHZ19                                // Add support for MH-Z19 CO2 sensor using hardware serial interface at 9600 bps (+1k1 code)
#define USE_MHZ19_SOFT_SERIAL                    // Add support for MH-Z19 CO2 sensor using software serial interface at 9600 bps (+2k3 code)
//  #define USE_SERIAL_NO_ICACHE                   // Use no iram with SoftwareSerial (may loose characters)

This disables WS2812 which uses a lot of iram and enables MHZ19 with standard SoftwareSerial support using iram. This should now not drop characters and therefore loose values.

Try again with GPIO4 and GPIO5.

@servim
Copy link

servim commented Dec 7, 2017

   #define USE_IR_REMOTE
// #define USE_IR_HVAC
   #define USE_IR_RECEIVE
// #define USE_WS2812
   #define USE_WS2812_CTYPE     1                 
// #define USE_WS2812_DMA 

// #define USE_MHZ19
   #define USE_MHZ19_SOFT_SERIAL
// #define USE_SERIAL_NO_ICACHE 
   #define USE_ARILUX_RF
Archiving built core (caching) in: C:\Users\sysadmin\AppData\Local\Temp\arduino_cache_623740\core\core_esp8266_esp8266_d1_mini_CpuFrequency_80,UploadSpeed_921600,FlashSize_4M1M_c90777c1f9e74f3d9082b972a2efb6fa.a
c:/arduino/arduino-sonoff/portable/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: C:\Users\sysadmin\AppData\Local\Temp\arduino_build_682099/sonoff.ino.elf section `.text' will not fit in region `iram1_0_seg'

collect2.exe: error: ld returned 1 exit status

Several libraries have been found for "SoftwareSerial.h"
 Used: C:\arduino\arduino-sonoff\portable\packages\esp8266\hardware\esp8266\2.3.0\libraries\SoftwareSerial
Not used: C:\arduino\arduino-sonoff\portable\sketchbook\libraries\EspSoftwareSerial-3.3.1
exit status 1
Compilation error for the board WeMos D1 R2 & mini.
// #define USE_IR_REMOTE
// #define USE_IR_HVAC
// #define USE_IR_RECEIVE

// #define USE_WS2812 
   #define USE_WS2812_CTYPE     1 
// #define USE_WS2812_DMA  
// #define USE_MHZ19
   #define USE_MHZ19_SOFT_SERIAL 
// #define USE_SERIAL_NO_ICACHE 
   #define USE_ARILUX_RF
Archiving built core (caching) in: C:\Users\sysadmin\AppData\Local\Temp\arduino_cache_623740\core\core_esp8266_esp8266_d1_mini_CpuFrequency_80,UploadSpeed_921600,FlashSize_4M1M_c90777c1f9e74f3d9082b972a2efb6fa.a
The sketch uses 473872 byte (45%) device memory. Total Available 1044464 байт.
Global variables use 45336 байт (55%) dynamic memory, leaving 36584 bytes for local variables. Maximum: 81920 байт.
Uploading 478016 bytes from C:\Users\sysadmin\AppData\Local\Temp\arduino_build_682099/sonoff.ino.bin to flash at 0x00000000
................................................................................ [ 17% ]
................................................................................ [ 34% ]
................................................................................ [ 51% ]
................................................................................ [ 68% ]
................................................................................ [ 85% ]
...................................................................              [ 100% ]

This works well.
Will it work MH-Z14?

@arendst
Copy link
Owner

arendst commented Dec 7, 2017

I don't know if MH-Z14 works. I'll have to look into the protocol.

@bashlikova
Copy link
Author

it works now with MH-Z14! Great work!
image

#define USE_MHZ19 // Add support for MH-Z19 CO2 sensor using hardware serial interface at 9600 bps (+1k1 code)
//#define USE_MHZ19_SOFT_SERIAL // Add support for MH-Z19 CO2 sensor using iram free software serial interface at 9600 bps (+2k3 code)

@bashlikova bashlikova closed this Dec 7, 2017
arendst added a commit that referenced this pull request Dec 8, 2017
5.10.0a
 * Add (experimental) support for sensor SHT3x
 * Add support
for sensor MH-Z19(B) using serial interface to be enabled with define
USE_MHZ19_HARD_SERIAL in user_config.h (#561, #1248)
 * Add
(experimental) support for sensor MH-Z19(B) using SoftwareSerial to be
enabled with define USE_MHZ19_SOFT_SERIAL_OBSOLETE in user_config.h
(#561, #1248)
 * Add (experimental) support for sensor MH-Z19(B) using
stripped SoftwareSerial to be enabled with define USE_MHZ19_SOFT_SERIAL
in user_config.h (#561, #1248)
 * Add support for iTead SI7021
temperature and humidity sensor by consolidating DHT22 into AM2301 and
using former DHT22 as SI7021 (#735)
 * Fix BME280 calculation (#1051)
 *
Add support for BME680 using adafruit libraries (#1212)
 * Change
ADS1115 default voltage range from +/-2V to +/-6V (#1289)
 * Add
multipress support and more user configurable options to Sonoff Dual R2
(#1291)
 * Fix Sonoff Bridge missed learned key if learned data contains
0x55 (End of Transmission) flag (#1095, #1294)
 * Add support for
TSL2561 using adafruit library (#661, #1311)
 * Add alternative support
for SHT3x (#1314)
arendst added a commit that referenced this pull request Dec 19, 2017
* Add support for sensor MH-Z19(B) to be enabled with define USE_MHZ19
in user_config.h (#561, #1248)
arendst added a commit that referenced this pull request Jan 7, 2018
5.11.0 20180107
 * Minor webpage HTML optimizations (#1358)
 * Updated
German translation (#1438)
 * Change Sonoff Pow Energy MQTT data message
and consolidate Status 8 into Status 10
 * Change ADS1115 default
voltage range from +/-2V to +/-6V (#1289)
 * Change text to Active for 3
minutes (#1364)
 * Change Wemo SetBinaryState to distinguish from
GetBinaryState (#1357)
 * Change output of HTTP command to valid JSON
and Array only (#1363)
 * Removed all MQTT, JSON and Command language
defines from locale files and set fixed to English (#1473)
 * Renamed
commands Color2,3,4 to Color3,4,5
 * Fix BME280 calculation (#1051)
 *
Fix Sonoff Bridge missed learned key if learned data contains 0x55 (End
of Transmission) flag (#1095, #1294)
 * Fix PWM initialization in
Dimmer/Color mode (#1321)
 * Fix Wemo Emulation (#1357)
 * Fix display
of build date and time in non-english locale (#1465)
 * Fix Wemo and Hue
emulation by adding M-Search response delay (#1486)
 * Add libraries
Adafruit_BME680-1.0.5, Adafruit_Sensor-1.0.2.02, TasmotaSerial-1.0.0 and
TSL2561-Arduino-Library
 * Add command Color2 to set color while keeping
same dimmer value
 * Add device function pointers
 * Add support for
SenseAir S8 CO2 sensor
 * Add color led signal to Carbon Dioxide (CO2)
sensors using defines CO2_LOW and CO2_HIGH in user_config.h
 * Add
support for Domoticz Air Quality sensor to be used by MH-Z19(B) and
SenseAir sensors
 * Add support for PZEM004T energy sensor
 * Add
support for iTead SI7021 temperature and humidity sensor by
consolidating DHT22 into AM2301 and using former DHT22 as SI7021 (#735)

* Add support for BME680 using adafruit libraries (#1212)
 * Add support
for MH-Z19(B) CO2 sensor (#561, #1248)
 * Add multipress support and
more user configurable GPIO to Sonoff Dual R2 (#1291)
 * Add support for
TSL2561 using adafruit library (#661, #1311)
 * Add support for SHT3x
(#1314)
 * Add support for Arilux LC06 (#1414)
 * Add Italian language
file (#1449)
 * Add 2nd Gen Alexa support to Wemo emulation discovery
(#1357, #1450)
 * Add define for additional number of WS2812 schemes
(#1463)
joecotton pushed a commit to joecotton/Sonoff-Tasmota that referenced this pull request Jan 8, 2018
5.11.0 20180107
 * Minor webpage HTML optimizations (arendst#1358)
 * Updated
German translation (arendst#1438)
 * Change Sonoff Pow Energy MQTT data message
and consolidate Status 8 into Status 10
 * Change ADS1115 default
voltage range from +/-2V to +/-6V (arendst#1289)
 * Change text to Active for 3
minutes (arendst#1364)
 * Change Wemo SetBinaryState to distinguish from
GetBinaryState (arendst#1357)
 * Change output of HTTP command to valid JSON
and Array only (arendst#1363)
 * Removed all MQTT, JSON and Command language
defines from locale files and set fixed to English (arendst#1473)
 * Renamed
commands Color2,3,4 to Color3,4,5
 * Fix BME280 calculation (arendst#1051)
 *
Fix Sonoff Bridge missed learned key if learned data contains 0x55 (End
of Transmission) flag (arendst#1095, arendst#1294)
 * Fix PWM initialization in
Dimmer/Color mode (arendst#1321)
 * Fix Wemo Emulation (arendst#1357)
 * Fix display
of build date and time in non-english locale (arendst#1465)
 * Fix Wemo and Hue
emulation by adding M-Search response delay (arendst#1486)
 * Add libraries
Adafruit_BME680-1.0.5, Adafruit_Sensor-1.0.2.02, TasmotaSerial-1.0.0 and
TSL2561-Arduino-Library
 * Add command Color2 to set color while keeping
same dimmer value
 * Add device function pointers
 * Add support for
SenseAir S8 CO2 sensor
 * Add color led signal to Carbon Dioxide (CO2)
sensors using defines CO2_LOW and CO2_HIGH in user_config.h
 * Add
support for Domoticz Air Quality sensor to be used by MH-Z19(B) and
SenseAir sensors
 * Add support for PZEM004T energy sensor
 * Add
support for iTead SI7021 temperature and humidity sensor by
consolidating DHT22 into AM2301 and using former DHT22 as SI7021 (arendst#735)

* Add support for BME680 using adafruit libraries (arendst#1212)
 * Add support
for MH-Z19(B) CO2 sensor (arendst#561, arendst#1248)
 * Add multipress support and
more user configurable GPIO to Sonoff Dual R2 (arendst#1291)
 * Add support for
TSL2561 using adafruit library (arendst#661, arendst#1311)
 * Add support for SHT3x
(arendst#1314)
 * Add support for Arilux LC06 (arendst#1414)
 * Add Italian language
file (arendst#1449)
 * Add 2nd Gen Alexa support to Wemo emulation discovery
(arendst#1357, arendst#1450)
 * Add define for additional number of WS2812 schemes
(arendst#1463)
curzon01 pushed a commit to curzon01/Tasmota that referenced this pull request Sep 6, 2018
Add (experimental) support for sensor MH-Z19(B) to be enabled with
define USE_MHZ19 in user_config.h (arendst#561, arendst#1248)
curzon01 pushed a commit to curzon01/Tasmota that referenced this pull request Sep 6, 2018
Add experimental support for sensor MH-Z19(B) using SoftwareSerial to be
enabled with define USE_MHZ19 in user_config.h (arendst#561, arendst#1248)
curzon01 pushed a commit to curzon01/Tasmota that referenced this pull request Sep 6, 2018
5.10.0a
 * Add (experimental) support for sensor SHT3x
 * Add support
for sensor MH-Z19(B) using serial interface to be enabled with define
USE_MHZ19 in user_config.h (arendst#561, arendst#1248)
 * Add (experimental) support
for sensor MH-Z19(B) using SoftwareSerial to be enabled with define
USE_MHZ19 in user_config.h (arendst#561, arendst#1248)
 * Add support for iTead SI7021
temperature and humidity sensor by consolidating DHT22 into AM2301 and
using former DHT22 as SI7021 (arendst#735)
 * Fix BME280 calculation (arendst#1051)
 *
Add support for BME680 using adafruit libraries (arendst#1212)
 * Change
ADS1115 default voltage range from +/-2V to +/-6V (arendst#1289)
 * Add
multipress support and more user configurable options to Sonoff Dual R2
(arendst#1291)
 * Fix Sonoff Bridge missed learned key if learned data contains
0x55 (End of Transmission) flag (arendst#1095, arendst#1294)
 * Add support for
TSL2561 using adafruit library (arendst#661, arendst#1311)
 * Add alternative support
for SHT3x (arendst#1314)
curzon01 pushed a commit to curzon01/Tasmota that referenced this pull request Sep 6, 2018
curzon01 pushed a commit to curzon01/Tasmota that referenced this pull request Sep 6, 2018
5.10.0a
 * Add (experimental) support for sensor SHT3x
 * Add support
for sensor MH-Z19(B) using serial interface to be enabled with define
USE_MHZ19_HARD_SERIAL in user_config.h (arendst#561, arendst#1248)
 * Add
(experimental) support for sensor MH-Z19(B) using SoftwareSerial to be
enabled with define USE_MHZ19_SOFT_SERIAL_OBSOLETE in user_config.h
(arendst#561, arendst#1248)
 * Add (experimental) support for sensor MH-Z19(B) using
stripped SoftwareSerial to be enabled with define USE_MHZ19_SOFT_SERIAL
in user_config.h (arendst#561, arendst#1248)
 * Add support for iTead SI7021
temperature and humidity sensor by consolidating DHT22 into AM2301 and
using former DHT22 as SI7021 (arendst#735)
 * Fix BME280 calculation (arendst#1051)
 *
Add support for BME680 using adafruit libraries (arendst#1212)
 * Change
ADS1115 default voltage range from +/-2V to +/-6V (arendst#1289)
 * Add
multipress support and more user configurable options to Sonoff Dual R2
(arendst#1291)
 * Fix Sonoff Bridge missed learned key if learned data contains
0x55 (End of Transmission) flag (arendst#1095, arendst#1294)
 * Add support for
TSL2561 using adafruit library (arendst#661, arendst#1311)
 * Add alternative support
for SHT3x (arendst#1314)
curzon01 pushed a commit to curzon01/Tasmota that referenced this pull request Sep 6, 2018
* Add support for sensor MH-Z19(B) to be enabled with define USE_MHZ19
in user_config.h (arendst#561, arendst#1248)
@Jason2866 Jason2866 mentioned this pull request Sep 1, 2020
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants