Site icon Renzo Mischianti

DHT12 Esp8266 (D1Mini) OneWire conections & blynk

thanks a loot!! i use DHT12 Esp8266 (D1Mini) OneWire conections & blynk :
//
//in blynk app use label value V0 and V1 for read data
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT12.h>
#include <Wire.h> //The DHT12 uses I2C comunication.
DHT12 dht12(D4, true);
// 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[] = "********";
BlynkTimer timer;
void myTimerEvent() {
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V9, millis() / 1000);
float tmp = dht12.readTemperature();
float hum = dht12.readHumidity();
Serial.printf("Temperatura: %2.2f*C Wilgotnosc: %0.2f%%\r\n", tmp, hum);
Blynk.virtualWrite(V0, tmp);
Blynk.virtualWrite(V1, hum);
}
void setup() { // Debug console
Serial.begin(9600);
dht12.begin();
Blynk.begin(auth, ssid, pass);
timer.setInterval(2000L, myTimerEvent); }
void loop() { Blynk.run(); timer.run(); // Initiates BlynkTimer }
Exit mobile version