MiCS-4514 SEN0377 OX and RED data is updating; always 0ppm
Hello,
After writing the code and kept it running overnight it is noticed that the readouts of the MEMS MiCS-4514 are never changing for the various gasses, but the OX and RED data is changing.
Performing a basic test, i used a small amount of Whiskey to evaporate near the sensor, which changed the OX and RED values. Though the C2H5OH shows always 0 ppm. NO2 always shows 10ppm which is the max.
As a precaution i bought 2 of these sensors and they give exactly the same results. So it must be a coding issue…???
Code:
//
//
//
#include "defines.h"
#include "enums.h"
#include "LoopMetrics.h"
#include "LogWriter.h"
#include "I2C_Driver.h"
#pragma region PUBLIC FUNCTIONS
void I2C_DriverClass::Init()
{
uint32_t speed = 100000;
Wire.begin((int)I2C_SDA, (int)I2C_SCL, speed);
mics = new DFRobot_MICS_I2C(&Wire, 0x75);
while (!mics->begin()) {
Serial.println("NO Deivces !");
delay(1000);
} Serial.println("Device connected successfully !");
uint8_t mode = mics->getPowerState();
if (mode == SLEEP_MODE)
{
mics->wakeUpMode();
Serial.println("wake up sensor success!");
}
else
{
Serial.println("The sensor is wake up mode");
}
}
void I2C_DriverClass::ExecuteTask()
{
float gasdata = mics->getGasData(CH4);
String results = "CH4,";
results += String(gasdata) + ",";
gasdata = mics->getGasData(C2H5OH);
results += "C2H5OH,";
results += String(gasdata) + ",";
gasdata = mics->getGasData(H2);
results += "H2,";
results += String(gasdata)+ ",";
gasdata = mics->getGasData(NH3);
results += "NH3,";
results += String(gasdata);
gasdata = mics->getGasData(CO);
results += "CO,";
results += String(gasdata) + ",";
gasdata = mics->getGasData(NO2);
results += "NO2,";
results += String(gasdata) + ",";
int16_t ox_data = 0;
int16_t red_data = 0;
ox_data = mics->getADCData(OX_MODE);
red_data = mics->getADCData(RED_MODE);
results += "ox data,";
results += String(ox_data) + ",";
results += "red data,";
results += String(red_data);
LogWriter.ConsoleOutputLn(results);
}
results:
11:57:32.499 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,805,red data,448
11:57:37.499 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,805,red data,448
11:57:42.499 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,805,red data,449
11:57:47.499 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,805,red data,449
11:57:52.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,805,red data,449
11:57:57.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,805,red data,449
11:58:02.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,805,red data,450
11:58:07.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,805,red data,449
11:58:12.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,805,red data,449
11:58:17.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,805,red data,450
11:58:22.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,805,red data,451 ←- started adding some alcohol vapour
11:58:27.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,805,red data,445
11:58:32.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,804,red data,328
11:58:37.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,803,red data,372
11:58:42.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,804,red data,281
11:58:47.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,801,red data,202
11:58:52.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,802,red data,432
11:58:57.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,803,red data,447
11:59:02.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,798,red data,158
11:59:07.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,397
11:59:12.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,801,red data,398
11:59:17.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,802,red data,434
11:59:22.498 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,797,red data,174
11:59:27.497 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,796,red data,258
11:59:32.497 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,408
11:59:37.497 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,798,red data,226
11:59:42.497 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,796,red data,263
11:59:47.497 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,797,red data,284
11:59:52.497 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,798,red data,262
11:59:57.497 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,798,red data,350
12:00:02.497 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,462
12:00:07.497 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,797,red data,269
12:00:12.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,322
12:00:17.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,271
12:00:22.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,798,red data,297
12:00:27.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,798,red data,318
12:00:32.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,389
12:00:37.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,467
12:00:42.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,797,red data,178
12:00:47.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,797,red data,318
12:00:52.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,792,red data,173
12:00:57.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,796,red data,361
12:01:02.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,798,red data,500
12:01:07.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,477
12:01:12.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,796,red data,276
12:01:17.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,797,red data,445
12:01:22.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,798,red data,353
12:01:27.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,437
12:01:32.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,451
12:01:37.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,438
12:01:42.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,385
12:01:47.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,801,red data,482
12:01:52.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,801,red data,448
12:01:57.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,251
12:02:02.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,797,red data,339
12:02:07.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,439
12:02:12.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,388
12:02:17.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,296
12:02:22.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,325
12:02:27.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,372
12:02:32.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,396
12:02:37.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,385
12:02:42.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,427
12:02:47.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,795,red data,166
12:02:52.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,798,red data,445
12:02:57.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,796,red data,178
12:03:02.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,796,red data,257
12:03:07.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,796,red data,195
12:03:12.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,797,red data,384
12:03:17.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,797,red data,295
12:03:22.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,419
12:03:27.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,798,red data,191
12:03:32.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,797,red data,334
12:03:37.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,797,red data,334
12:03:42.496 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,798,red data,366
12:03:47.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,798,red data,324
12:03:52.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,357
12:03:57.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,399
12:04:02.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,356
12:04:07.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,351
12:04:12.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,441
12:04:17.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,438
12:04:22.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,390
12:04:27.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,280
12:04:32.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,398
12:04:37.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,798,red data,250
12:04:42.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,301
12:04:47.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,386
12:04:52.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,797,red data,193
12:04:57.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,382
12:05:02.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,333
12:05:07.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,797,red data,196
12:05:12.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,433
12:05:17.495 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,505 ←- closed the bottle containing a small quantity of Whiskey :-)
12:05:22.494 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,799,red data,519
12:05:27.494 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,519
12:05:32.494 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,521
12:05:37.494 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,800,red data,521
12:05:42.493 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,801,red data,519
12:05:47.493 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,801,red data,520
12:05:52.492 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,801,red data,521
12:05:57.492 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,802,red data,520
12:06:02.492 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,802,red data,519
12:06:07.492 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,802,red data,519
12:06:12.492 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,802,red data,518
12:06:17.492 - (Debug) - CH4,0.00,C2H5OH,0.00,H2,0.00,NH3,0.00CO,0.00,NO2,10.00,ox data,802,red data,516 ←- results return to normal though 0 ppm on all except NO2 which is always 10ppm
After reading the code, there is a baseline reading in the ‘Warmup’ routine. When you don't call warmup the system is not initializing the baseline reading and all values are wrong. This driver is poorly written and worse of it is that the values being read are all over the place.
Exposing the sensor to methanol only also triggers nh3 ch4 and other compound readings.
can't recommend this sensor to anyone except for a rudimentary detection of something in the air.
Martin.Meuwese