I HAVE A PROBLEM WITH THE FOLLOWING CODE.
EVERYTHING WORKS I SEE THE DATA IN THE SERIAL MONITOR BUT IN THE GAUGE TEMPERATURE AND HUMIDITY APP BLINK DOES NOT RECEIVE ANY DATA.
WHO CAN HELP ME
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "XXXXXXXXXXXXXXX";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "XXXXXXXXXXXXX";
char pass[] = "XXXXXXXXX";
#include <DHT.h>
#define DHTPIN 14 // what pin we're connected to
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22
DHT dht(DHTPIN, DHTTYPE);
#define BLYNK_GREEN "#23C48E"
#define BLYNK_RED "#D3435C"
#define BLYNK_BLUE "#04C0F8"
float t, h;
float setpoint;
int value = 0;
BlynkTimer timer;
WidgetLED led1(V1);
// 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 h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Blynk.virtualWrite(V3,h);
Blynk.virtualWrite(V4,t);
// You can send any value at any time.
// Please don't send more that 10 values per second.
Serial.println(h);
Serial.println(t);
if ((setpoint > t ) && (value == 1)) {
digitalWrite(5, LOW);
} else {
digitalWrite(5, HIGH);
}
}
void ledCaldaia()
{
if (digitalRead(5) == 1) {
Serial.println("RELE OFF");
led1.off();
led1.setColor(BLYNK_BLUE);
} else {
Serial.println("RELE ON");
led1.on();
led1.setColor(BLYNK_RED);
}
}
void setup() {
// Debug console
Serial.begin(9600);
dht.begin();
timer.setInterval(5000L, sendSensor);
timer.setInterval(2000L, ledCaldaia);
Blynk.begin(auth, ssid, pass);
digitalWrite(5, HIGH);
pinMode(5, OUTPUT); // rele caldaia
}
BLYNK_CONNECTED() {
Blynk.syncAll();
}
void loop() {
Blynk.run();
timer.run();
}
BLYNK_WRITE(V2)
{
setpoint = param.asInt(); // Get value as integer
Serial.println(setpoint);
}
BLYNK_WRITE(V0)
{
value = param.asInt(); // Use param as usual.
Serial.println(value);
}