// Including the ESP8266 WiFi library #include // Including the DHT library #include "DHT.h" // Uncomment one of the lines below for whatever DHT sensor type you're using! //#define DHTTYPE DHT11 // DHT 11 //#define DHTTYPE DHT21 // DHT 21 (AM2301) #define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 // DHT Sensor const int DHTPin = D4; // Initialize DHT sensor. DHT dht(DHTPin, DHTTYPE); void setup() { Serial.begin(9600); //Output to Serial at 9600 baud //connectWifi(); // Start ConnecWifi Serial.print("\n"); Serial.println("ChipId: "); Serial.println(ESP.getChipId()); dht.begin(); delay(10000); } void loop() { float h = dht.readHumidity(); // Read temperature as Celsius (the default) float t = dht.readTemperature(); if (isnan(h) || isnan(t)) { Serial.println("Failed to read from DHT sensor!"); } else { Serial.print("Humidity: "); Serial.print(h); Serial.println("%"); Serial.print("Temperature: "); Serial.print(t); Serial.println("°C"); } delay(5000); }