BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

ESP8266 WiFiClient and Blynk: no data from clients

Hi,
first of all I’m new with Blynk.
I have an external small weather station (with ESP8266) that sends data from sensors every 10 minutes to another ESP8266 equipped with a 2.8" LCD display that shows data and sends data to Blynk.
The connection between ESP8266s is made through WiFiClient library, everything has worked without problems until I added code to send data to Blynk.
When the weather station connects to the “display station”, on this last I can read (from serial monitor) that the client connects but then nothing else happens and data seems not to be received.
This is the code that reads data from the weather station (“loop()” routine):

  client = server.available();
  if (client)
  {
      if (client.connected()) 
      {
           Serial.println("Connected to client");
      }
      if (client.available() > 0)
      {
          // Read incoming message
          String strDati = client.readString();
          Serial.println(strDati);
          ...code to process data and then send to Blynk
      }
  }

When the weather station connects, the message “Connected to client” appears on the serial monitor but then nothing else happens…it seems that the line "if (client.available() > 0) " is not true and then subsequent code is not executed.
If I disable the “Blynk code”, everything works again.
What should I check?
Thank you, best regards.

Roberto

Blynk isn’t designed to be used with this slave to master, master to Blynk type of architecture.

Pete.

So if I got what you mean, should I send data directly from the weather station?
Consider that the weather station goes into deep sleep for 10 minutes (and then wakes up) and the “display station” measure indoor temperature/humidity and I would like to send also those data.
Isn’t there another solution?

There are lots of solutions, but quite a bit depends on which version of Blynk you are using and what other things you are wanting to achieve - either now or in the future.

If you’re using Blynk IoT with the free subscription then you have two devices available. One cold be your deep-sleep weather station and the other your indoor display station.

Both could independently send data to the Blynk server, but the devil is in the detail of whether you want to write that weather station data back to the indoor display station, and whether you want results from both devices displayed on a single scree in the app and web dashboard.

If that is your aim then you’d probably need to use the Blynk API to “bridge” the outdoor data across to the indoor display station.

If you want to do other stuff, like turn things on/off when the temperature, humidity, wind speed, light level, rainfall etc exceed certain values then a different approach might be on the cards.

I do a lot of stuff based on data from my weather station and indoor sensors, such as turning extractor fans on if the indoor humidity in one room is significantly higher than outside, closing sun blinds if it starts to rain or the wind speed gets too high, turning outside lights on/off based on brightness etc etc. Is anything like this in your ling-term objectives?

Pete.

I fixed the issue…I removed the line

if (client.available() > 0)

and actually it received data from the weather station even though “client.available=0” so now it’s working correctly.
I found very interesting what you implemented with your weather station, I won’t be so “sophisticated” but considering what Blynk can do…you never know :wink:
Thank you, regards.

Roberto

1 Like

Most of my logic and data processing is done in Node-Red, with the individual devices sending data and receiving commands via MQTT messaging, which is routed via my Node-Red/MQTT server.
Blynk acts as a mobile app and web dashboard front-end interface to this system.

Pete.