Virtual pins doesn't work

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. :point_up: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();

}

Is it up to date?

I don t use a local server, but that doesn’t seem like the correct syntax to me.

Pete.

As @PeteKnight stated, your code is connecting the Cloud server… not your Local Server.

Did you just setup the Local Server?

Are you aware that they are two distinctly different servers and thus you MUST first log into it with the App, create a new account and new projects…

You can not simply use old existing projects from the cloud without first cloning them over and resetting them up with new Auth codes and proper IPs in the sketches for the Local Server.

1 Like