/*************************************************************
This example shows how value can be pushed from Arduino to
the Blynk App.
WARNING :
For this example you'll need Adafruit DHT sensor libraries:
https://github.com/adafruit/Adafruit_Sensor
https://github.com/adafruit/DHT-sensor-library
App project setup:
Value Display widget attached to V5
Value Display widget attached to V6
*************************************************************/
// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID "TMPLNkccPHpR"
#define BLYNK_DEVICE_NAME "testingwokwi"
#define BLYNK_AUTH_TOKEN "vrd5VcJ877j2eoi8xqmtLiqNew0skX0_"
// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <DHTesp.h>
#include <LiquidCrystal_I2C.h>
char auth[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
DHTesp dht;
#define DHT_PIN 33
LiquidCrystal_I2C LCD = LiquidCrystal_I2C(0x27, 20, 4);
// Set the LC I2C address
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21 // DHT 21, AM2301
//DHT dht(DHTPIN, DHTTYPE);
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 sendSensor()
{
float humidity = dht.getHumidity();
float temperature = dht.getTemperature();
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
LCD.setCursor(5,0);
LCD.print("Humidity: ");
LCD.setCursor(7,1);
LCD.print(humidity);
LCD.print(" %");
LCD.setCursor(5,2);
LCD.print("Temp: ");
LCD.setCursor(7,3);
LCD.print(temperature);
LCD.println(" Celcius");
delay(2000); //Delay 2 sec between temperature/humidity check.
Blynk.virtualWrite(V2, humidity);
Blynk.virtualWrite(V1, temperature);
}
void setup()
{
// Debug console
Serial.begin(115200);
LCD.init();
LCD.backlight();
LCD.setCursor(0, 0);
LCD.print("ESP32&&DHT22&&BLYNK");
LCD.setCursor(4, 1);
LCD.print("WEATHER CHANNEL");
LCD.setCursor(9, 2);
LCD.print("&");
LCD.setCursor(5, 3);
LCD.print("CONTROL");
delay(5000);
LCD.clear();
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
dht.setup(DHT_PIN, DHTesp::DHT22);
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
}
void loop()
{
Blynk.run();
timer.run();
}
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
led1:A
led1:C
led2:A
led2:C
dht1:VCC
dht1:SDA
dht1:NC
dht1:GND
lcd1:GND
lcd1:VCC
lcd1:SDA
lcd1:SCL