nodmcu V3 (Lolin) DHT11 with DeepSleep

การหลับ Deepsleep จะเป็นหน่วย microsecond

#include <ESP8266WiFi.h>
#include “DHT.h”
//deep sleep  wire GPIO16 (D0) to RST Pin
#define DHTPIN D4 // ขา Out ของ Sensor ต่อเข้าขา D4 ของ Esp8266
#define DHTTYPE DHT11 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
dht.begin();
Serial.begin(9600);
Serial.println(“Humidity and temperature\n\n”);
delay(700);
}

void loop()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print(“Current humidity = “);
Serial.print(h);
Serial.print(“% “);
Serial.print(“temperature = “);
Serial.print(t);
Serial.println(“C “);
//ESP.deepSleep(30e6); // Deep sleep mode for 30 seconds
//ESP.deepSleep(60e6); // Deep sleep mode for 60 seconds
ESP.deepSleep(300e6); // Deep sleep mode for (~5 min) 300 seconds
delay(800);
}

credit:https://roboindia.com/tutorials/DHT11-NodeMCU-arduino