Is it possible in blynk to gather sensor data from other device and send it to a master server and display the value?

What I am trying to achieve here as of now is simply turn on/off led of 5 different nodemcu and they all send the state of led to a master ESP32 which simply turn on the led on the esp32 of respective nodemcu device. Here a image which will explain what I’m trying to achieve. This needs to be done in blynk itself and no other option.

https://i.imgur.com/ja515nX.png

I’ve read this several times, and I’m still unsure exactly what you’re trying to achieve.

I think you mean that the statuses of the 5 LEDs connected to the ESP32 should mirror the statuses of the LEDs on the 5 individual ESP8266 devices.

What I’m not clear about is:

  • Are these physical LEDs or Blynk LED widgets (or both)
  • How are the LEDs on the 5 ESP8266 devices commanded on/off
  • What exactly do you mean a by this statement…

do you mean that you don’t want to write any code to make this happen, or something else?

Pete.

You are right. I need to mirror the status of led on the nodemcu to the esp32.

Are these physical LEDs or Blynk LED widgets (or both)

They are both. Turning led on/off on the nodemcu using simple blynk on/off widget. And the state of these led will need to be reflected on the esp32.

How are the LEDs on the 5 ESP8266 devices commanded on/off

Using blynk device dashboard (unique for every nodemcu, since on same wouldn’t be possible)

What exactly do you mean a by this statement…

What I mean is that I only want to blynk only for this project, no MQTT or ESPhome. In total there will be 6 devices. The 5 nodemcu dashboard will have only 1 on/off widget to turn the led on/off. The ESP on the other hand will only have the status of all the other nodemcu which means will have 5 on/off switch which will ONLY be used to monitor the state of led.

Have you looked at using Device State Automations for this?

If they don’t meet your needs then you can use the HTTP(S) API to transfer data from one Blynk device to another.

I can’t understand why you’d use switch widgets for this. LED widgets would make far more sense.
Personally, I would have thought that having one dashboard (the one for the ESP32) and using that to control all of the slave devices would have been a better way to achieve what you want.

Pete.

I wasnt able to understand how to use device state automation but I was able to figure out the way to use HTTP(S) API to fetch the data.

I had a question about the API, How often it is allowed to fetch the data? I mean is there any time limit before you fetch the data again?

Rather than using the API to fetch data (presumably you’re doing this on the ESP32) you’d probably be better using it to push data from each of your slave devices if the LED status changes.
This way, you aren’t polling each of the slave devices to see if their switch values have changed. Instead these devices will push the new value only when it changes.

Pushing data on a virtual pin in this way will automatically update an LED widget attached to that datastream, and will cause the `BLYNK_WRITE(vPin) callback for that pin to trigger, allowing you to switch physical LEDs at the same time.

There is some example code for you to use in the EP8266 link on this post…

As far as limits are concerned, I think the limit is 500,000 updates per 24 hour period…

Pete.

Sorry for late reply. Yes, I think sending data to the HTTP API would be better but I’m unable to do on nodeMCU, But I can do it on the ESP32, would you help me out with that?

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

const char *ssid = "wifi";
const char *password = "password";

const char *url = "https://blynk.cloud/external/api/update?token=SECRET_TOKEN&dataStreamId=2&value=1";

WiFiClient client;
HTTPClient httpClient;

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");

  sendPostRequest();
}

void loop() {

}

void sendPostRequest() {

  httpClient.begin(client, url);
  int httpResponseCode = httpClient.GET();

  if (httpResponseCode > 0) {
    Serial.print("HTTP Response code: ");
    Serial.println(httpResponseCode);
  } else {
    Serial.print("HTTP Error code: ");
    Serial.println(httpResponseCode);
  }


  httpClient.end();
}

So you didn’t like the ESP8266 code that I created for this, and linked to in one of my earlier replies?

Pete.

I wasnt able to understand that. :sweat_smile: I would appreciate if you tell me how to make it work.

Thanks

It’s a fully working sketch.

Pete.

OH MY BAD. I didn’t knew I had to click on the thread too. After Modifying that code a bit in order to make it work with blynk.run only, instead of BlynkEdgent and it works now. Thanks a lot for the help.