I can't read the Virtual Pin of LED Widget

Hi, I have a confusion to read a VPin. Before I start, I’ve looked some websites to get the idea behind this problem. The problem is really basic,

  • I’m using 2 ESP-01S modules to turn on/off relay according to DHT11.
  • I used the LED to display relay state on DHT11’s code which is “V5”.
  • When I try to write V5 it shows the correct value on LED widget, however it does not write to the relay.
  • I used the backup method, I defined a variable named testPin as V10. Then, I made V5 and V10 pins SET/RESET respectively according to the sensor. Their definitions are exactly the same. When I turn the relay ON/OFF with V10, it works successfully, but when I try with V5, the relay does not accept the values.

I guess LED Widget block to read value from another ESP01 module.

Edit: I did not use V10 on any widget. It just runs only on datastream.

Posting your whole sketch might help.

You’re probably best to start here:

The ESP-01 isn’t a great choice as ot only has two useable pins and is difficult to work with because of its form factor. Also, communication between two devices needs to be done via the Blynk server using Automations. Each ESP-01 needs to be a separate Blynk device with a unique auth token.

Pete.

Sorry for late answer @John93

    #define BLYNK_PRINT Serial
    // BLYNK Bilgileri
    #define BLYNK_TEMPLATE_ID "xxx"
    #define BLYNK_DEVICE_NAME "xxx"
    #define BLYNK_AUTH_TOKEN "xxx"
    // DHT Bilgileri
    #define DHTPIN 2        // 2. Dijital pine DHT11'i bağlıyoruz.
    #define DHTTYPE DHT11   // DHT 11
    
    #include "DHT.h"
    #include <WiFiManager.h>
    #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    
    DHT dht(DHTPIN, DHTTYPE);
    
    char auth[] = BLYNK_AUTH_TOKEN;
    
    float sicaklik, nem, istenenSicaklik, istenenNem;
    int kombiEnable, kombiDurumuLED;
    bool res; //WiFiManager için bağlantı kontrolü.
    
    BlynkTimer timer;
    
    BLYNK_WRITE(V1)
    {
      istenenSicaklik = param.asFloat();
    }
    
    BLYNK_WRITE(V3)
    {
      istenenNem = param.asFloat();
    }
    
    BLYNK_WRITE(V4)
    {
      kombiEnable = param.asInt();
    }
    
    void sensorBilgileriniGonder()
    {
      float nem = dht.readHumidity();
      float sicaklik = dht.readTemperature();
      /*
        if (isnan(nem) || isnan(sicaklik)) {
        Serial.println("DHT sensöründen veri okunamadı!");
        return;
        }
      */
      Blynk.virtualWrite(V0, sicaklik);
      Blynk.virtualWrite(V2, nem);
    
      if (kombiEnable == 1) {
        if (istenenSicaklik > sicaklik) {
          kombiDurumuLED = 1;
        }
        else {
          kombiDurumuLED = 0;
        }
      }
      else {
        kombiDurumuLED = 0;
      }
      Blynk.virtualWrite(V5, kombiDurumuLED);
      Blynk.virtualWrite(V10, kombiDurumuLED);
    }
    
    void setup() {
      Serial.begin(115200);
      WiFiManager wm;
    
      res = wm.autoConnect("AutoConnectAP", "password"); // password protected ap
    
      if (!res) {
        Serial.println("Bağlantı sağlanamadı!");
        ESP.restart();
      }
      else {
        dht.begin();
        Blynk.config(auth);
        //Blynk.begin(BLYNK_AUTH_TOKEN, "MFT", "MFT_95@45.");
        timer.setInterval(5000L, sensorBilgileriniGonder);
      }
    }
    
    void loop() {
      Blynk.run();
      timer.run();
    }

The relay side code is;

#define BLYNK_PRINT Serial
// BLYNK Bilgileri
#define BLYNK_TEMPLATE_ID "xxx"
#define BLYNK_DEVICE_NAME "xxx"
#define BLYNK_AUTH_TOKEN "xxx"
//Fiziksel IO
#define roleCikisi 0 // Kombi Aç/Kapat için bağlı olan röle'nin çıkışı

#include "DHT.h"
#include <WiFiManager.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;
int kombiEnable, kombiRoleCikisi;
bool res; //WiFiManager için bağlantı kontrolü.

BlynkTimer timer;

BLYNK_WRITE(V4)
{
  kombiEnable = param.asInt();
}

BLYNK_WRITE(V10)
{
  kombiRoleCikisi = param.asInt(); //Kullanmaktaki tek amaç, LED Status'u okuyamadığımız için Kombi Durumu'nu bu VPin aracılığıyla Röleye aktarmayı sağlar.
}

void roleBilgisiniGonder() {
  digitalWrite(roleCikisi, kombiRoleCikisi);
}

void setup() {
  pinMode(roleCikisi, OUTPUT);
  // Debug console
  Serial.begin(115200);
  WiFiManager wm;

  res = wm.autoConnect("AutoConnectAP", "password"); // password protected ap

  if (!res) {
    Serial.println("Bağlantı sağlanamadı!");
    ESP.restart();
  }
  else {
    Blynk.config(auth);
    //Blynk.begin(BLYNK_AUTH_TOKEN, "MFT", "MFT_95@45.");
    timer.setInterval(1000L, roleBilgisiniGonder);
  }
}

void loop() {
  Blynk.run();
  timer.run();
}

@mfatihtuz Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

Thanks for the suggestion. I’ll look at that post.

I never tried to use automation option, because the ESP-01 modules connecting the same “device on blynk app”. So thats why I never tried that option.

I’ll write after the automation option implementation.

Do you mean that you’re using the same Auth token on both devices?
If so then you should not be doing this.

Pete.

Why should not I do that? Or what should I do?

I edited code side with two apps, can you look at the codes please?

Blynk expects each device to have its own Auth token, and to establish its own continuous connection to the Blynk server.
If you don’t do this then you a you can’t monitor whether each individual device is online, as Blynk reports “Online” when either one of the two devices are connected to the server.
I suspect that in future, if the Blynk server detects two devices sharing the same Auth token it will kill one (or both) of the connections. This is because the Blynk billing system is based on device count, and you’re misusing the system when you have one Blynk device with two physical devices connected to it.

In addition, your relay code is using V4, when I suspect it should be using V5 instead, but this will be irrelevant when you stop sharing a single Auth token across two devices.

Pete.