hey there.
i got some issues with code… everything working, except i dont getting any data from dht sensor (temperature and humidity). so thats relay working on ESP12f and for getting data from dht sensor. relays working fine and DHT seems working, at least led light and it getting warm (means working).
I working both with web and android version - its just showing some same numbers for temp and humidity all time. here what i got set in blynk.console and code, thank you:
also, maybe you could tell me, how i can get text from serial as separate datastream?
#define BLYNK_TEMPLATE_ID "TM********p"
#define BLYNK_DEVICE_NAME "ESP12f 3DP"
#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define APP_DEBUG
// Uncomment your board, or configure a custom board in Settings.h
//#define USE_SPARKFUN_BLYNK_BOARD
//#define USE_NODE_MCU_BOARD
//#define USE_WITTY_CLOUD_BOARD
//#define USE_WEMOS_D1_MINI
#include "BlynkEdgent.h"
#include <DHT.h>
#include <SPI.h>
#define DHTPIN 1
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
BLYNK_CONNECTED() {
Blynk.syncAll();
}
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;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V1, h); //V1 is for Humidity
Blynk.virtualWrite(V2, t); //V2 is for Temperature
}
void setup()
{
Serial.begin(115200);
delay(100);
BlynkEdgent.begin();
dht.begin();
timer.setInterval(10000L, sendSensor);
digitalWrite(12, LOW); //default state is off
digitalWrite(5, LOW);
digitalWrite(3, LOW);
digitalWrite(13, LOW);
pinMode(3, OUTPUT); //laser
pinMode(5, OUTPUT); //power
pinMode(12, OUTPUT); //filter
pinMode(13, OUTPUT); //LEDs
}
BLYNK_WRITE(V3) // Executes when the value of virtual pin 1 changes
{
if(param.asInt() == 1)
{ // execute this code if the switch widget is now ON
digitalWrite(12,HIGH); // Set digital pin 2 HIGH
} else {
// execute this code if the switch widget is now OFF
digitalWrite(12,LOW); // Set digital pin 2 LOW
} }
BLYNK_WRITE(V4) // Executes when the value of virtual pin 1 changes
{
if(param.asInt() == 1)
{ // execute this code if the switch widget is now ON
digitalWrite(5,HIGH); // Set digital pin 2 HIGH
} else {
// execute this code if the switch widget is now OFF
digitalWrite(5,LOW); // Set digital pin 2 LOW
} }
BLYNK_WRITE(V5) // Executes when the value of virtual pin 1 changes
{
if(param.asInt() == 1)
{ // execute this code if the switch widget is now ON
digitalWrite(3,HIGH); // Set digital pin 2 HIGH
} else {
// execute this code if the switch widget is now OFF
digitalWrite(3,LOW); // Set digital pin 2 LOW
} }
BLYNK_WRITE(V6) // Executes when the value of virtual pin 1 changes
{
if(param.asInt() == 1)
{ // execute this code if the switch widget is now ON
digitalWrite(13,HIGH); // Set digital pin 2 HIGH
} else {
// execute this code if the switch widget is now OFF
digitalWrite(13,LOW); // Set digital pin 2 LOW
}
}
void loop()
{
BlynkEdgent.run();
timer.run();
}