Can't read 2nd temperature sensor

Hi guys i need help here this is the code that is running in my node mcu now the problem is i can read a temperataure from pin D7 but D8 pin is not sending any signal please help me and im using dht11 two temperature sensor

#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>
// float DHT11_h;
// float DHT21_h;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "0e5944ff5aea475xxxxxxed1483bed315";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "home";   
char pass[] = "12345678"; 
BlynkTimer timer;
DHT dht1(D8,DHT11);
DHT dht2(D7,DHT11);
//SimpleTimer timer;
void sendSensor()
  float DHT11_h = dht1.readHumidity();
  float DHT11_t = dht1.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(DHT11_h) || isnan(DHT11_t)) {
    Serial.println("Failed to read from DHT sensor!");
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, DHT11_h);
  Blynk.virtualWrite(V6, DHT11_t);

  //sensor 2
  float DHT21_h = dht2.readHumidity();
  float DHT21_t = dht2.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(DHT21_h) || isnan(DHT21_t)) {
    Serial.println("Failed to read from DHT sensor!");
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V3, DHT21_h);
  Blynk.virtualWrite(V4, DHT21_t);
void setup()
  Serial.begin(9600); // See the connection status in Serial Monitor
  Blynk.begin(auth, ssid, pass);
  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);

void loop()
  {; // Initiates Blynk; // Initiates SimpleTimer


i’m on phone now, so didn’t examined your code carefully, but chances are high that d8 is not a good solution for dht sensor. if i translated correctly, d8 == gpio15, which should be low during boot, so it probably has a built in pulldown resistor. this counter acts against the dht, which should have a pullup to work properly.

please, study this:

also, please make a habbit to use and refer to gpio pin numbering (that is universal among all esp boards), not the d8 and alike namings. those are dumb and meaningless naming convention.

other suggesrions:

  • you should put the Blynk.virtualWrites into the if statement, to send value only if sensor was readed succesfully

  • do not use dht11 sensors, as they are very bad quality. use dht22 instead.

i changed from D8 to D0 that is i.e gpio16 but nothing works please help are of give me a proper code for combing two dht11 sensor

Have you even read the post? It links to a document which says gpio16 also has a special function, so please look at the post and wire your DHT accordingly. We are not a code factory. Some initiative is appreciated…


yeah already im using D3,D4,D5,D6 for switch and D7 for temp sensor 1 and now i want temp sensor 2 to be working no other pins left so i thought of using D8 only but i, getting problem here so help me i should submit this project to my college with in 2 days please help

Then what is the problem with switching to another GPIO? Choose one from those used by switches (but look at table @wanek made for us) , and move the switch to D8, changing logic if necessary.

the problem is i have already assigned so commands in google assistant so now i cant change every command in google assistant and still D0,D1,D2 left ie gpio16,gpio05,gpio04 and i tried to change the value of that but nothing worked so please help me guys only 80 hours left for me to submit the project

Well, good news is you seem to have doubled your time needed :stuck_out_tongue:

There is no magical “help” button that we can press to solve your issue. You may have to start from scratch, armed with the better knowledge others have provided, and double down on your rebuilding efforts within your deadline. Remember, this is your academic responsibility, not ours :wink:

1 Like