//hammadiqbal12@gmail.com #define BLYNK_PRINT Serial #include #include #include "DHTesp.h" #ifdef ESP32 #pragma message(THIS EXAMPLE IS FOR ESP8266 ONLY!) #error Select ESP8266 board. #endif int Sensor_PIN = 0; //D3 DHTesp dht; // You should get Auth Token in the Blynk App. // Go to the Project Settings (nut icon). char auth[] = ""; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = ""; char pass[] = ""; float Temperature; float Humidity; BlynkTimer timer; // This function sends Arduino's up time every second to Virtual Pin (5). // In the app, Widget's reading frequency should be set to PUSH. This means // that you define how often to send data to Blynk App. void myTimerEvent() { Temperature = dht.getTemperature(); // Gets the values of the temperature Humidity = dht.getHumidity(); // Gets the values of the humidity // You can send any value at any time. // Please don't send more that 10 values per second. Blynk.virtualWrite(V5, Temperature); Blynk.virtualWrite(V6, Humidity); } void setup() { // Debug console Serial.begin(9600); dht.setup(Sensor_PIN, DHTesp::DHT11); Blynk.begin(auth, ssid, pass); // You can also specify server: //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80); //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080); // Setup a function to be called every second timer.setInterval(1000L, myTimerEvent); } void loop() { Blynk.run(); timer.run(); // Initiates BlynkTimer }