ESP32 and ccs811 sensor

Hi, I have a ccs811 sensor connected to the ESP32 D1 mini. I have updated my libraries. It seems to me that co2 is slightly higher than reality. And the temperature is much higher. Has anyone met with that? Thanks


 
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include "Adafruit_CCS811.h"
 
Adafruit_CCS811 ccs;
#include <SI7021.h>
SI7021 sensor; 

char auth[] = "";
char ssid[] = "";
char pass[] = "";

BlynkTimer timer;

void sendSensor()
{

int temperature = sensor.getCelsiusHundredths()/100;
int humidity = sensor.getHumidityPercent();
Blynk.virtualWrite(3, temperature); 
Blynk.virtualWrite(4, humidity); 

ccs.readData();
int c = ccs.geteCO2();
Blynk.virtualWrite(V2, c);

 
int TVOC = ccs.getTVOC();
Blynk.virtualWrite(V7, TVOC); 



} 
void setup()
{
  // Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  ccs.begin();

 
  // Setup a function to be called every second
  timer.setInterval(31000L, sendSensor);

  
}
 
void loop()
{
  Blynk.run();
  timer.run();
}

Here we discuss only Blynk related issues. It looks like you need to calibrate your sensor. This has nothing to do with Blynk in my opinion.

I don’t think because with this simple code the values are normal

#include "Adafruit_CCS811.h"
 
Adafruit_CCS811 ccs;
 
void setup() {
Serial.begin(9600);
 
Serial.println("CCS811 test");
 
if(!ccs.begin()){
Serial.println("Failed to start sensor! Please check your wiring.");
while(1);
}
 
//calibrate temperature sensor
while(!ccs.available());
float temp = ccs.calculateTemperature();
ccs.setTempOffset(temp - 25.0);
}
 
void loop() {
if(ccs.available()){
float temp = ccs.calculateTemperature();
if(!ccs.readData()){
Serial.print("CO2: ");
Serial.print(ccs.geteCO2());
Serial.print("ppm, TVOC: ");
Serial.print(ccs.getTVOC());
Serial.print("ppb Temp:");
Serial.println(temp);
}
else{
Serial.println("ERROR!");
while(1);
}
}
delay(500);
}

The sample code it taking a reading every 500ms and your ii taking a reading every 31000ms.

The sample code also applies a -25.0 degrees offset to the temperature and your code doesn’t.

Compare these extremely different pieces of code and say that the differences in readings are due to the use of Blynk.

Pete.

I dont see this correction factor in your code. Things are totally different.

of course I tried to change: 31000ms and add: ccs.setTempOffset(temp - 25.0); nothing helps the problem is somewhere else but I don’t know where …

Remove the blynk part from the code and serial print the readings.

Remove the blynk part from the code? but I want to be able to monitor the values of the Blynk application …

The suggestion is an attempt to prove to you that the issue isn’t Blynk related, but if you don’t want to try that then what’s the point in asking for advice?

Pete.