error reading humidity module bme280+ccs811 v1
![userHead](https://dfimg.dfrobot.com/dfPortrait2.png)
Hi, i have a problema with the module bme280+ccs811 v1, the humidity goes from 0 to 100 repeatedly.
This is the module: https://store.arduino.cc/products/multi-function-environmental-module-ccs811-bme280
This is the documentation I followed: https://wiki.dfrobot.com/Multi_function_Environmental_Module_CCS811_BME280_SKU_SEN0335
And this is the Sketch (i use Arduino IOT cloud):
/*
Sketch generated by the Arduino IoT Cloud Thing “Meteo”
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
String taratura;
float alti;
float humi;
float temp;
int co2;
int press;
int tvoc;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#include "DFRobot_CCS811.h"
DFRobot_CCS811 CCS811;
#include "DFRobot_BME280.h"
#include "Wire.h"
typedef DFRobot_BME280_IIC BME; // ******** use abbreviations instead of full names ********
BME bme(&Wire, 0x76); // select TwoWire peripheral and set sensor address
#define SEA_LEVEL_PRESSURE 1015.0f
// show last sensor operate status
void printLastOperateStatus(BME::eStatus_t eStatus)
{
switch (eStatus) {
case BME::eStatusOK: Serial.println("everything ok"); break;
case BME::eStatusErr: Serial.println("unknow error"); break;
case BME::eStatusErrDeviceNotDetected: Serial.println("device not detected"); break;
case BME::eStatusErrParameter: Serial.println("parameter error"); break;
default: Serial.println("unknow status"); break;
}
}
void setup(void) {
// Initialize serial and wait for port to open:
Serial.begin(9600);
/*Wait for the chip to be initialized completely, and then exit*/
while (CCS811.begin() != 0) {
Serial.println("failed to init chip, please check if the chip connection is fine");
delay(1000);
}
bme.reset();
Serial.println("bme read data test");
while (bme.begin() != BME::eStatusOK) {
Serial.println("bme begin faild");
printLastOperateStatus(bme.lastOperateStatus);
delay(2000);
}
Serial.println("bme begin success");
delay(100);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
qualitaAria();
tempPress();
ArduinoCloud.update();
delay(10000);
}
void qualitaAria() {
if (CCS811.checkDataReady() == true) {
Serial.print("CO2: ");
Serial.print(CCS811.getCO2PPM());
Serial.print("ppm, TVOC: ");
Serial.print(CCS811.getTVOCPPB());
Serial.println("ppb");
co2 = CCS811.getCO2PPM();
tvoc = CCS811.getTVOCPPB();
} else {
Serial.println("Data is not ready!");
}
/*!
@brief Set baseline
@param get from getBaseline.ino
*/
CCS811.writeBaseLine(0x83B9);
//delay cannot be less than measurement cycle
delay(1000);
}
void tempPress() {
temp = bme.getTemperature();
//uint32_t press = bme.getPressure();
press = bme.getPressure();
alti = bme.calAltitude(SEA_LEVEL_PRESSURE, press);
humi = bme.getHumidity();
Serial.println();
Serial.println("======== start print ========");
Serial.print("temperature (unit Celsius): "); Serial.println(temp);
Serial.print("pressure (unit pa): "); Serial.println(press);
Serial.print("altitude (unit meter): "); Serial.println(alti);
Serial.print("humidity (unit percent): "); Serial.println(humi);
Serial.println("======== end print ========");
delay(1000);
}
this is an excerpt of the serial output (do not look at the C02 and TVOC, they are not correct, I have to redo the calibration):
======== start print ========
temperature (unit Celsius): 31.08
pressure (unit pa): 92579
altitude (unit meter): 776.40
humidity (unit percent): 100.00
======== end print ========
CO2: 2681ppm, TVOC: 2159ppb
======== start print ========
temperature (unit Celsius): 31.08
pressure (unit pa): 92578
altitude (unit meter): 776.40
humidity (unit percent): 100.00
======== end print ========
CO2: 2669ppm, TVOC: 2143ppb
======== start print ========
temperature (unit Celsius): 31.08
pressure (unit pa): 92578
altitude (unit meter): 776.40
humidity (unit percent): 0.00
======== end print ========
How can I solve the problem of humility? i have another module like this but it still gives me the same problem.
Thanks!
Jex.
Hi! When using the sample code for these two sensors alone, is there a problem with the output?
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)