Hi Blynkers,
I want to use the Numeric Input (V4) in void sendSensor(), how can i do this or why doent it work?
#define BLYNK_PRINT Serial
#include <SimpleDHT.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
int pinDHT22 = D4;
SimpleDHT22 dht22;
char auth[] = "c9f29bf559e343bbbac12bb0ad6ad2ed";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Kaffee7490";
char pass[] = "83270062622472273261";
WidgetLED led1(V0);
WidgetLED led2(V1);
WidgetLED led3(V7);
BlynkTimer timer;
BLYNK_WRITE(V3) {
int Zeit = param.asInt();
if (Zeit == 1)
{
led1.on();
led2.off();
}
else
{led2.on();
led1.off();
}
}
BLYNK_WRITE(V4)
{
Boxtemperatur = param.asFloat();
}
void sendSensor()
{
float temperature = 0;
float humidity = 0;
int err = SimpleDHTErrSuccess;
if ((err = dht22.read2(pinDHT22, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
Serial.print("Read DHT22 failed, err="); Serial.println(err); delay(2000);
return;
}
Serial.print(Boxtemperatur);
Serial.println(temperature);
Blynk.virtualWrite(V2, temperature);
if (temperature < Boxtemperatur)
{led3.on();}
else
{led3.off();}
}
void setup()
{
// Debug console
Serial.begin(9600);
timer.setInterval(2000L, sendSensor);
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
}
void loop()
{
Blynk.run();
timer.run();
}