Hello,
I have a problem with my code because impossible to read virtualpins from my Smartphone. No Data are transfered. No problems to read the analog or digital pins. I have already test the virtual pins withb another sketchs but it is the first time that it happens.
details :
• Arduino UNO with ESP8266
• Smartphone OS Android + version
• local server
• Blynk Library version 0.5.4
• Add your sketch code. Code should be formatted as example below.
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <DHT.h>
#include <math.h>
const int flameAnalog = A5; // Flame analog Sensor connect to A5
const int pinLuminSensor = A2; // Grove - Luminusité Sensor connect to A2
const int flameDetect = 4; // Flame detect sensor connect to D4
long tempMax = 50;
int tempStatus = 0;
#define DHTPIN 5 // DTH11 connected to D5
#define DHTTYPE DHT11 // DHT 11
char auth[] = "";
char ssid[] = "";
char pass[] = "";
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
BLYNK_WRITE(V11)
{
tempMax = param.asLong();
}
void sendSensors()
{
//Température et humidité
float humidity = dht.readHumidity();
float temperature = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
//Luminusité
float lumin = analogRead(pinLuminSensor);
lumin = map(lumin, 0, 800, 0, 10);
//Flamme
float flame = (1024 - analogRead(flameAnalog));
int flameDet = digitalRead(flameDetect);
Blynk.virtualWrite(V6, humidity);
Blynk.virtualWrite(V7, temperature);
Blynk.virtualWrite(V8, flameDet);
Blynk.virtualWrite(V9, flame);
Blynk.virtualWrite(V10, lumin);
Blynk.virtualWrite(V12, tempStatus);
Serial.print("*** Temperature = ");
Serial.println(temperature);
Serial.print(" +++ Température de consigne = ");
Serial.print(tempMax);
Serial.print(" +++ TempStatus = ");
Serial.println(tempStatus);
Serial.print(" --- Humidity = ");
Serial.println(humidity);
Serial.print(" **** Luminusité = ");
Serial.println(lumin);
Serial.print("Flame Sensor Value: ");
Serial.print(flame);
Serial.print(" Flame Detect : ");
Serial.println(flameDet);
if (digitalRead(flameDet) == HIGH){
Serial.println(" Flame Detected");
}
if (temperature > tempMax){
if (tempStatus == 0) {
Blynk.notify("La température a dépassé la température de consigne");
tempStatus = 255;
}
}
else tempStatus = 0;
}
void setup()
{
// Debug console
Serial.begin(9600);
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
timer.setInterval(10000L, sendSensors);
}
void loop()
{
Blynk.run();
timer.run();
}