DHT11 and DHT22

Wow, it looks nice. Could you post it to the “Projects made with Blynk” category?
BTW, now Blynk supports sending String objects, so you may skip using toCharArray… Enjoy!

Hi,

which DHT library did you use?

I want to try this as well on ESP8266

Thanks
Nico

Here is one I did this weekend, using a Arduino Nano V3, ESP8266 as a Shield and a DHT22 connected to Pin 2:

#include <ESP8266.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <DHT.h>
#include <SimpleTimer.h>

#define DHTPIN 2
#define DHTTYPE DHT22   // DHT 22 Change this if you have a DHT11
DHT dht(DHTPIN, DHTTYPE);

// Set ESP8266 Serial object
#define EspSerial Serial

ESP8266 wifi(EspSerial);

SimpleTimer timer;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "Your Auth Token";

void setup()
{
 //No Serial console as the Nano only has 1 HW Serial
  EspSerial.begin(115200);  // Set ESP8266 baud rate
  delay(10);

  Blynk.begin(auth, wifi, "YourSSID", "Your Wifi PWD");

  timer.setInterval(1000, sendData);
}

void sendData()
{
//Read the Temp and Humidity from DHT
  float h = dht.readHumidity();
  float t = dht.readTemperature();

//Write values to V04 and V05
  Blynk.virtualWrite(4, h);
  Blynk.virtualWrite(5, t);
}

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

Which Library did you use? Could you link it or upload it please?

I used the one from here: https://github.com/adafruit/DHT-sensor-library

1 Like

I got Blynk to work on my ESP and DHT11,



Nice and easy!
I am getting errors trying to compile the code to use the ESP as a shield though.

@sel303, For the shield configuration, please read instructions in the sketch carefully. you need a modified ITEAD library.

1 Like

Doh! I figured it out. I was trying to compile it for the ESP. Changed the board to UNO and it compiles fine. Thanks!

Thx to yptsai7 your code works perfectly. Close to 10 days testing now. Is there a way to implement sleep with this code?

Would love it if my esp could run on battery for a month.

I use Notification widget on Android too, but never get a notify. Do you succeed in that? BTW, I use Blynk library with ESP8266 on my Nexus 4.

Did you activated dashboard? Please show your code that sends notifications. Notifications are working. So most probably problem somewhere in your code.

For deep sleep low power - you need to tie pins 13 and 16 (XPD and RST) - then just add in Arduino ide:
ESP.deepSleep(60000000, WAKE_RF_DEFAULT); // Sleep for 60 seconds

the -03 is fairly easy - there are pads to solder together to tie the reset to XPD, -01 is harder.

I’m using one (esp8266-03) with the adafruit dht library and put it to sleep for 10 minutes, then it wakes up, connects, gets a reading and publishes to thingspeak. I’m just starting with Blynk and enjoying this thread :wink:

I did and it worked on my nexus 5. It would notify when the esp was disconnected.

Well the thing is that blynk app does not show anything when esp is offline. There would have to be some buffer or something on the server.

I didn’t dig deep into the feature but it did occasionally tell me "esp8266 " was offline.

I put Blynk.notify("why don't you popup?"); in void setup(), after the connection is set up.

@juncaofish

Like this

while (!Blynk.connect()) {
// Wait until connected
}

// Notify immediately on startup
Blynk.notify(“why don’t you popup?”);

?

Yes! Anything wrong? Hopefully I can fix this.

Code is ok. Did you add notification widget to your dashboard? Your dashboard active?

Yes. I add it and the dashboard is activated. The Mail widget once didn’t work for me. But now it’s OK.
However, I don’t get any luck on Notification widget.
Thanks for your reply.