Hello,
I’m really newbie at Blynk community and i’m having some issues on my project. I’m making a demonstration of IOT using the Blynk app (school project), using the ESP8266 to read data from some sensors (up to now just DHT11, how you can see in the code) and control some leds and a buzzer. I have a button on the blynk app and when it is pressed , i want a phisically LED to repeatedly blink by determined period of time. I haven’t found anything in the forum that worked
Here’s the code (ignore the comments in portuguese, the important is indicated).
#define BLYNK_PRINT Serial
#define DHTPIN 13 // Pino Digital do Sensor de Temperatura
#define DHTTYPE DHT11 // Tipo do sensor (DHT 11)
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266_SSL.h> // Definindo Bibliotecas
#include <DHT.h>
char auth[] = "authauthauthauthauth"; // Auth Token do app Blynk
char ssid[] = "HELP"; // Credenciais WIFI (Nome,Senha)
char pass[] = "INeedSomebody";
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
void sendSensor() { // Esta função envia as informções coletadas pelo
// sensor para o app Blynk
float h = dht.readHumidity();
float t = dht.readTemperature(); // No Blynk a função deve estar no modo "PUSH"
if (isnan(h) || isnan(t)) {
Serial.println("Erro na leitura do sensor!");
return;
}
Blynk.virtualWrite(V5, h); // Umidade
Blynk.virtualWrite(V6, t); // Temperatura
// Condicional do ar condicionado (LED) ligar:
if (t>=35){ // "Se temperatura (t) for maior ou igual a 35, ligar LED"
digitalWrite (12, HIGH);
}
if (t<=28) {
digitalWrite (12,LOW); // "Se a t for menor que 28, desligar LED (economia de energia)"
}
}
///////////////////////////////////////////////////////////////////////////////
BLYNK_WRITE(V2) // Here's the part i'm having trouble with
{
int pinValue = param.asInt();
Serial.print("V2 value is: "); // Virtual Button : V2
Serial.println(pinValue);
if(pinValue==1){
digitalWrite (15, HIGH); // LED pin : 15
delay(100);
digitalWrite (15, LOW);
delay(100);
}
//////////////////////////////////////////////////////////////////////////
void setup() { // Inicia o programa (baud rate: 9600)
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
dht.begin();
timer.setInterval(1000L, sendSensor); // Envia as informações a cada 1 segundo
}
void loop() { // "Blynk" rodando junto
Blynk.run();
timer.run();
}
I couldn’t format properly…
Sorry for my bad english and really thanks for any assistance and the patience.