[SOLVED] NodeMCU and DHT22

I have been trying to get a simple Temperature System going using a NodeMCU (ESP8266) and DHT22 Sensor.

I can successfully get it working locally on an UNO but when I try to use it on Blynk I cant get it to work…
I have read and Read the forms and tried a dozen different scripts to no avail…
Any help would be greatly appreciated. My Script is below

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

#include <DHT.h>
#define DHTPIN 5
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE, 15); 

char auth[] = "XXX";

SimpleTimer timer;
float humidity, temp;  // Values read from sensor

void sendUptime()
{
  Blynk.virtualWrite(V5, millis() / 1000);
}

BLYNK_READ(1) 
{ 
temp = dht.readTemperature();
Blynk.virtualWrite(V13,temp); 
}
BLYNK_READ(2) 
{ 
humidity = dht.readHumidity();     
Blynk.virtualWrite(V14,humidity);  
}
void setup()
{
  Serial.begin(9600); 
  Blynk.begin(auth, "XXX", "XXX");
  dht.begin();  

  timer.setInterval(1000L, sendUptime);
}

void loop()
{
  Blynk.run(); // Initiates Blynk
  timer.run(); // Initiates SimpleTimer
}

You haven’t told us what is not working!

Oops your right, I seem to get frequent drop outs the App says its gone offline comes back quick enough but i wonder if my timer in the script is wrong?. Should I be setting the widgets to push or what interval should I be reading them at? I would like to have about 4 sensors polling in the future.

Thank you for your quick reply

So the temperature shows on the app or not?

Set all to push…

Yes the Temperature and Humidity show up, I will set the widgets to push and see if that helps with the drop outs.
:slight_smile:

Setting everything to push helped me with my esp8266 set up…