Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WiFi.h>
- #include <DHT.h>
- #include <esp_sleep.h>
- #define DHTPIN 4
- #define DHTTYPE DHT22
- DHT dht(DHTPIN, DHTTYPE);
- void setup() {
- Serial.begin(115200);
- dht.begin();
- esp_sleep_enable_timer_wakeup(10 * 60 * 1000000); // Set to wake up every 10 minutes
- }
- void loop() {
- float temperature = dht.readTemperature();
- float humidity = dht.readHumidity();
- if (isnan(temperature) || isnan(humidity)) {
- Serial.println("Failed to read from DHT sensor!");
- return;
- }
- Serial.print("Temperature: ");
- Serial.print(temperature);
- Serial.print(" *C, Humidity: ");
- Serial.print(humidity);
- Serial.println(" %");
- esp_deep_sleep_start(); // Enter deep sleep mode
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement