Problem in connect some sensors to Esp32

Hello everyone
I have a problem in my project which is project for indoor air quality monitoring. I use four sensors which is for detects:

  1. volatile organic compound I use (CCS811 sensor)

  2. temperature as humidity I use dht11

  3. Co2 I use MQ-135

  4. Co I use MQ-7

And all of these I connected with ESp32 microcontroller and connect them to Blynk cloud. All reads of sensor is okay and can I show it in Blynk app.

But my problem is when I connect CCS811 sensor it disable the dht11, which means there is no reads is freeze in Blynk! As shown in this picture below. In addition to there is no error in code it uploaded successfully and also I use it before its work and reads it shown in Blynk! But when I connected a CCS811 , the dht11 is freeze and read is stop.

And this is my code

#define BLYNK_TEMPLATE_ID ""
#define BLYNK_DEVICE_NAME "IAQM"
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
#include "Adafruit_CCS811.h"
 
Adafruit_CCS811 ccs;


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

#define DHTTYPE DHT11
#define DHTPIN 34
float mq135 = 36;
float mq7 = 39;
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

void sendSensor()
{
//DHT11  
  float h = dht.readHumidity();
  float t = dht.readTemperature(); 

  Blynk.virtualWrite(V1, t);
  Blynk.virtualWrite(V2, h);
  
//MQ-135
 float datAA = analogRead(mq135); 
  Blynk.virtualWrite(V3, datAA);

  //MQ-7
 float data2 = analogRead(mq7); 
  Blynk.virtualWrite(V4, data2);

  //CCS811

    ccs.readData();
    int TVOC = ccs.getTVOC();
    Blynk.virtualWrite(V5, TVOC);
  
}


void setup()
{
 
  Serial.begin(9600);
  dht.begin();
  Serial.println("CCS811 test"); 
   If (!ccs.begin() {
    Serial.println("Faild to start CCS"); 
    while(1);
  }

while (!css.available() ) ;
  Blynk.begin("", ssid, pass);
  timer.setInterval(1000L, sendSensor);
  
}

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

Why are you doing a ccs.begin() each time you want to read the sensor?

How are your sensors wired-up?

What do you see in your serial monitor?

Is it just the DHT sensor that stops working?

Pete.

But you do have…

so if you’re not seeing anything then you have a problem.

I’d also suggest adding some additional serial print commands to help your diagnosis, and I’d add some NAN checking to your DHT sensor code too.

That sounds like it might be a driver conflict issue, but not Blynk related.

Pete.

Does it work if you only use the CCS811?

Don’t know if it relates to your problem, but your sampling rate is too high for the DHT11! Use 5 seconds or more in your timer.

2 Likes

I tried only dht11 it’s works. I see the temperature and humidity in serial monitor. But when I use it CCS811 with it, is stop.

I don’t know where is the problem exactly…

I’ve suggested several ways to help you diagnose this, but you don’t seem interested.

Pete.

Yes. When I use only CCS811 It’s works.

Another thing, I tried 500L which is 5sec and it same, not work

500L is half a second, 5 seconds is 5000

1 Like

No I’m so much interested. The deadline of my project it’s after 2 weeks, but I don’t have a knowledge about these things. May I don’t know what is your solutions! Actually I’m Information technology student not an electronic circuits student or somthing. Also I tried your solution and it’s not work

Maybe you should re-read this topic from the beginning.

Pete.

1 Like

Thank you appreciate it. I will do and try it.

Thanks all. Problem is solved