This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems Adding MH-Z19B CO2 sensor to AQM
#1
Dear All,

I've had my Air Quality Monitor up and running for a few weeks now with just the air quality sensor installed. All has been fine until I added a MH-Z19B CO2 sensor today. After configuring the code and uploading, I get no AQ or CO2 readings on the Rx unit. The serial monitor output I get is below. Changing the #define USE_CO2 back = 0 restores the AQ reading.

Any ideas on what might be wrong would be much appreciated....

Rgds,

Zak



WeatherDuino 4Pro
Air Quality Monitor v8.0 b001

Please wait 30s
Configuring CO2 Sensor
Setting measurement range to: 5000
FF,99,1,0,0,0,0,0,66,
66,66
Measurement range changed!
Disabling ABC Funtion
Reseting Sensor
21,10,A0,FD,0,0,0,1,35,
Calculated crc: 52
Wrong reply from CO2 sensor!
FF,86,1,9A,3C,0,0,0,A3,
Calculated crc: A3
CO2 read: 431 - Temp: 20

FF,86,1,9A,3C,0,0,0,A3,
Calculated crc: A3
CO2 read: 431 - Temp: 20

FF,86,1,9A,3C,0,0,0,A3,
Calculated crc: A3
CO2 read: 431 - Temp: 20

FF,86,1,9A,3C,0,0,0,A3,
Calculated crc: A3
CO2 read: 431 - Temp: 20

FF,86,1,9A,3C,0,0,0,A3,
Calculated crc: A3
CO2 read: 431 - Temp: 20

FF,86,1,9A,3C,0,0,0,A3,
Calculated crc: A3
CO2 read: 431 - Temp: 20

FF,86,1,9A,3C,0,0,0,A3,
Calculated crc: A3
CO2 read: 431 - Temp: 20

FF,86,5,E4,3C,0,0,0,55,
Calculated crc: 55
CO2 read: 1585 - Temp: 20

FF,86,5,D9,3C,0,0,0,60,
Calculated crc: 60
CO2 read: 1573 - Temp: 20

Init MH-Z19 Ended

FF,86,5,F8,3C,0,0,0,41,
Calculated crc: 41
CO2 read: 0 - Temp: 20


My config_options are:

Code:
// --------------------------------------------------------------------------------------
//   WeatherDuino - Air Quality Monitor v8.0 b001
//            User Configurable Options
// --------------------------------------------------------------------------------------

// --------------------------------------------------------------------------------------
//   Define ID and TX unit number
// --------------------------------------------------------------------------------------
const byte Station_ID = 0xA1;    // Must be equal to your RX Unit (Value from 0x00 to 0xFF)


// --------------------------------------------------------------------------------------
//   Define type of PM sensor
// --------------------------------------------------------------------------------------
#define PMSENSOR_TYPE   0    // 0= PMS7003, 1= nova SDS011


// --------------------------------------------------------------------------------------
//   For the PMS7003 define data set
// --------------------------------------------------------------------------------------
#define PMS7003_DATASET 1    // 0= CF1, 1= Ambiente (You should always use this data set)


// --------------------------------------------------------------------------------------
//   CO2 (MH-Z19) Settings
//   Note: For outside use, the MH-Z19B model produces more accurate results
// --------------------------------------------------------------------------------------
#define USE_CO2         1    // 0= Not instaled, 1= Instaled
#define Z19_MODEL       2    // 1= Model A, 2= Model B  (ATTENTION: Make sure you select the correct model)                            

// Set measure range                              
#define Z19_RANGE       5    // Don't change (Keeps default factory range 0..5000 ppm)
                            // Valid values for Model A: 1= 1000ppm, 2= 2000ppm, 3= 3000ppm, 5=5000ppm
                            // Valid values for Model B: 2= 2000ppm, 5= 5000ppm

#define ABC_FUNCTION    0    // 0= Disable, 1= Enable (For outside use, ABC function should be disabled)                            

int16_t CO2_OffSet   = 0;    // Fine adjust to compensate sensor error (This value should be determined case by case. Values between -50 and 50)

// --------------------------------------------------------------------------------------
//   Define type of Temperature / Humidity sensor
// --------------------------------------------------------------------------------------
#define TH_SENSOR    3       // 1= HTU21D, 2= SHT2x, 3=SHT3x  


// --------------------------------------------------------------------------------------
//   Enable / Disable RF data transmission
// --------------------------------------------------------------------------------------
#define TX_MODE      1       // 0= No data will be transmitted via RF, 1= Transmit Data


// --------------------------------------------------------------------------------------
//   Enable / Disable LCD Display
// --------------------------------------------------------------------------------------
#define LCD_DISPLAY  0       // 0= Disable Display, 1= Enable Display


// --------------------------------------------------------------------------------------
//   SHT31 I2C Address - Default address will work most of the times!
// --------------------------------------------------------------------------------------
#define SHT31_ADDRESS 0x44       // Default value is 0x44, but it can be changed to 0x45

// --------------------------------------------------------------------------------------
//   Debug helper on Serial Monitor
// --------------------------------------------------------------------------------------
//#define DEBUG_PM      // Uncomment for debug help
#define DEBUG_CO2     // Uncomment for debug help
Reply
#2
Hi Zak,

The Config_Options seems good (supposing the CO2 sensor is a model B) as also the output of DEBUG_CO2. You may also enable the DEBUG_PM to check if the Dust sensor is being read. The Dust sensor should be read 40s after the end of the CO2 init sequence.
After checking that both sensors are being read, disable both Debug options and upload the code again.
When both sensors are in use, data may take a little more time to be updated on the receiver (1 to 3 minutes).

Please report back.

Regards
MeteoCercal - Air Quality Data
Click here to watch at my ThingSpeak channel



Reply
#3
(22-02-2019, 02:10)Werk_AG Wrote: Hi Zak,

The Config_Options seems good (supposing the CO2 sensor is a model B) as also the output of DEBUG_CO2. You may also enable the DEBUG_PM to check if the Dust sensor is being read. The Dust sensor should be read 40s after the end of the CO2 init sequence.
After checking that both sensors are being read, disable both Debug options and upload the code again.
When both sensors are in use, data may take a little more time to be updated on the receiver (1 to 3 minutes).

Please report back.

Regards

Hi Werk,

Yes, the sensor is a model B unit.

When I enable both debug lines only the CO2 sensor is being read. It now produces the following output. No matter how long I leave it, the dust sensor is never read and the unit does not transmit data to the Rx:


Quote:WeatherDuino 4Pro
Air Quality Monitor v8.0 b001

Please wait 30s
Configuring CO2 Sensor
Setting measurement range to: 5000
3C,94,13,C3,6,40,C,D,5F,
37,5F
Disabling ABC Funtion
Reseting Sensor
80,CD,8,EE,0,0,0,1,0,
Calculated crc: 3C
Wrong reply from CO2 sensor!
2,EE,0,0,0,1,0,80,0,
Calculated crc: 91
Wrong reply from CO2 sensor!
3,EE,0,0,0,1,0,80,0,
Calculated crc: 91
........ETC
     


However, If I set the CO2 sensor as enabled (#define USE_CO2 = 1) and only enable the dust sensor debug line, the dust sensor is read (see below) and data is sent to the Rx unit, but the CO2 reading is 65535PPM!

Quote:Air Quality Monitor v8.0 b001

Please wait 30s

Waking up the dust sensor...
Reading will be done 40s later.

Reading the dust sensor...

PMS7003 readings:
PM2.5: 27.00 ug/m3
PM10 : 27.00 ug/m3
PM2.5_1H_Avg : 27.00
PM2.5_NowCast: 27.00

When I disable both debug lines and upload the code with the CO2 sensor enabled, no data is sent to the Rx unit. I have also noticed that when the CO2 sensor is enabled the 'L' LED on the nano is always lit. When the CO2 sensor is disabled, this LED is never lit. Not sure if this is correct?

If I then disable the CO2 sensor (#define USE_CO2=0) then the dust sensor is read once only and the data is transmitted to the Rx.

Kind regards,

Zak
Reply
#4
Hi Zak,

I'm not sure about what is causing the described problem, anyway I have published an updated software version. Please try it and report back.
Make sure you compile it with AVR Boards Manager 1.6.21. newer versions are causing problems with some WeatherDuino software (boards using Nano and Mega only).
Thank you.

Kind regards,
Werk_AG
MeteoCercal - Air Quality Data
Click here to watch at my ThingSpeak channel



Reply
#5
(23-02-2019, 04:18)Werk_AG Wrote: Hi Zak,

I'm not sure about what is causing the described problem, anyway I have published an updated software version. Please try it and report back.
Make sure you compile it with AVR Boards Manager 1.6.21. newer versions are causing problems with some WeatherDuino software (boards using Nano and Mega only).
Thank you.

Kind regards,
Werk_AG

Hi Werk_AG,

Sorry it's taken me a while to get back to you.

Thank you for publishing an updated version and for your time considering this problem. Unfortunately it does not seem to have solved the issue. The PM reading is fine, but the CO2 sensor still returns a value of 65535PPM:

https://photos.app.goo.gl/ErmwFwLm2a9QuEbQ9

The serial monitor output is below. The CO2 initiation seems to be working fine, followed by the first reading of the dust sensor. However, the subsequent reading of the CO2 monitor returns a dust value of 0....

Kind regards,

Zak

Quote:   WeatherDuino 4Pro
Air Quality Monitor v8.0 b002

Please wait 30s
Configuring CO2 Sensor
Setting measurement range to: 5000
FF,99,1,0,0,0,0,0,66,
66,66
Measurement range changed!
Disabling ABC Funtion
Reseting Sensor
E1,90,1C,FC,0,1,0,3,0,
Calculated crc: 54
Wrong reply from CO2 sensor!
FF,86,1,9A,3A,0,0,0,A5,
Calculated crc: A5
CO2 read: 441 - Temp: 18

FF,86,1,9A,3A,0,0,0,A5,
Calculated crc: A5
CO2 read: 441 - Temp: 18

FF,86,1,9A,3A,0,0,0,A5,
Calculated crc: A5
CO2 read: 441 - Temp: 18

FF,86,1,9A,3A,0,0,0,A5,
Calculated crc: A5
CO2 read: 441 - Temp: 18

FF,86,1,9A,3A,0,0,0,A5,
Calculated crc: A5
CO2 read: 441 - Temp: 18

FF,86,1,9A,3A,0,0,0,A5,
Calculated crc: A5
CO2 read: 441 - Temp: 18

FF,86,1,9A,3A,0,0,0,A5,
Calculated crc: A5
CO2 read: 441 - Temp: 18

FF,86,4,2F,3A,0,0,0,D,
Calculated crc: D
CO2 read: 1136 - Temp: 18

FF,86,4,2D,3A,0,0,0,F,
Calculated crc: F
CO2 read: 1134 - Temp: 18

Init MH-Z19 Ended


Waking up the dust sensor...
Reading will be done 40s later.

Reading the dust sensor...

PMS7003 readings:
PM2.5: 23.00 ug/m3
PM10 : 24.00 ug/m3
PM2.5_1H_Avg : 23.00
PM2.5_NowCast: 23.00

FF,86,4,27,3A,0,0,0,15,
Calculated crc: 15
CO2 read: 0 - Temp: 18
Reply
#6
(24-02-2019, 23:33)Zack_ster Wrote: The serial monitor output is below. The CO2 initiation seems to be working fine, followed by the first reading of the dust sensor. However, the subsequent reading of the CO2 monitor returns a dust value of 0....

Hi Zak,

Please check if the Temp / Hum sensor of the AQM board is working correctly, also make sure you are using latest software both in the RX and WD unit.
What AVR board version are you using?

Regards
MeteoCercal - Air Quality Data
Click here to watch at my ThingSpeak channel



Reply
#7
(25-02-2019, 01:23)Werk_AG Wrote:
(24-02-2019, 23:33)Zack_ster Wrote: The serial monitor output is below. The CO2 initiation seems to be working fine, followed by the first reading of the dust sensor. However, the subsequent reading of the CO2 monitor returns a dust value of 0....

Hi Zak,

Please check if the Temp / Hum sensor of the AQM board is working correctly, also make sure you are using latest software both in the RX and WD unit.
What AVR board version are you using?

Regards


All fixed  Smile .

The SHT31 temperature sensor was faulty and producing no output. Running the Adafruit SHT31 example code revealed the issue. I had not suspected it as the debug output of the CO2 sensor included a temperature value so I assumed it was working.

Quote:FF,86,4,2D,3A,0,0,0,F,
Calculated crc: F
CO2 read: 1134 - Temp: 18


I really appreciate your speedy help and suggestions. Thanks.

Zak
Reply
#8
Hi Zak,

I'm glad to know that it is working now.
My suggestions were based on the clear reports you did. Thank you.
MeteoCercal - Air Quality Data
Click here to watch at my ThingSpeak channel



Reply




Users browsing this thread: 1 Guest(s)