Use ESP NOW to transfer a sensor value between two ESPs in blynk

If you’re building a home automation system for yourself then you really should consider going down the Node-Red route. It make this data consolidation process much simpler, and it allows you to build your own rules engine within Node-Red, as well as adding Alexa or Google Home voice assistant integration in a very simple and effective way.

Pete.

1 Like

Thanks I’m trying to convince the employer to use Node-Red :white_heart:

If you want to use Blynk commercially then you should be using the Plus plan at least.

Pete.

Panels are very expensive (in my country)
And I do not need it because only one person or one phone wants to know the temperature of several places. And if necessary, turn the air conditioner or heater on and off manually or automatically
Hopefully I get the desired result with node -red Thank you

Actually, what I wrote earlier was a typo by me. It should have said that if you want to use Blynk commercially then you need to have at least a PRO plan.

Otherwise, you are breaching the terms and conditions of Blynk, and you may find that your account is suspended.

Pete.

1 Like

Thank you for your information

Hi Amir,
Sorry if you cant use my code. I have no videos etc, Just this GitHub publish.

My code is designed for low power devices/sensors, battery operated. And/or solar panel operated. I have therefore optimized for the lowest possible energy/power consumption possible by code. And therefore rejected many other “implementation easier ways” which results in more energy consumption. Which you can afford if you run devices on USB 5V. Different thing.

If you run on 5V USB, you could skip ESP-Now since it may be a bit tricky (or techie) and quite “non-standard”.
(I use ESP-Now quite general anyway as I have built parts of my system on such technology and it is very reliable once working. Actually, my ESPNow-ESP/WiFiGateways-Blynk systems are the most reliable parts and least cumbersome of all my sub-systems.)

If your application is to display 2 temp sensors in 1 same “blynk IOT device” and you run the sensors on 5V USB, you can have another approach.

  • The general idea is to SEND sensor data from 2 (or more) devices to 1 device which is CONNECTED to Blynk.
    This can be done in several ways. Some have already been mentioned above.
    I cannot really recommend the “best” way as a) i don’t know, and b) it differs much from your requirements, complexity and skills, etc.

I have used the following two ways:

  1. Sensors send data using TCP or UDP to the 1 device connected to Blynk. This device provides data for typically 8 sensors to Blynk in one same page/app.
  • This solution is quite simple. No additional hardware is required. You must however learn how to send /and receive between ESP devices using TCP/UDP. Lots of examples can be found on internet and this forum (?). I think there exist examples in the Arduino IDE also.
    Note: The temp sensors don’t know anything about blynk, they just send to 1 esp device who is connected to blynk.

A variant of this is probably (?) to let the temp sensors send directly to the blynk datastream direct using their API. It should be possible. But, I have never tried it and I guess this is one more non-standard way that most likely will meet some challenges and problems. I would avoid trying this.

  1. Node-RED.
    Node-RED is a separate software that allows for very easy integration between devices (and other things). It is easy, using available s.c. Blynk Contribs to read and write sensor data between Node-Red and Blynk. The Node-RED will be 1 device vs Blynk and all data sent from Node-Red can be displayed in one and same blynk page/app.

The thing is a) how to run Node-RED and b) how to get data into Node-RED?

a) Node-RED is a software that must be running all the time. You therefore need to install it on a “server” of some kind. It can be a windows desktop (if running all the time) or better a Raspberry Pi (I do). You therefore will need a separate HW to buy, install, maintain and operate. You install Node-RED on chosen server. (I run it on Raspberry PI which works good but do require time to “maintain”.)

b) You also then need a way to send temp sensors from ESP to the Node-Red. A very popular way is to use MQTT (I do). If so, your ESP’s must send (=publish) data to MQTT, and you should have an MQTT broker (=server) running somewhere. It could be external (Adafruit IO offers 10 feeds for free) or you could use the very popular (and stable) Mosiquitto installed on your Raspberry Pi. The Mosquitto and Node-Red works very well and stable. My experience says me, the MQTT publishing from ESP is not super stable. It works good if ESP is only sending (*) but if your ESP is doing something else also, then this becomes a bit unstable.

(*) I use the PubSubclient library on ESP8266 and it seems to have problems in stability as soon as you do anything else on WiFi than publishing. If I Subscribe (receives) on same device or if i want to use a web server to display data, or … it too often gets disconnected, looses wifi, gets unresponsive, hangs or just slow. Not all the time, but far to often to be reliable. It might be my code which is wrong. (I am trying to improve this …)

=>
My recommendation (even if I said I would not recommend) would be:

  • Try to send from one ESP using more standard TCP/UDP to another ESP which is connected to Blynk. This second ESP is connected to Blynk as 1 device using standard blynk communication methods.

I believe this is much easier and will not require more HW and software.

// I do use Node-RED myself but for such a simple application I would not.

My 25 cents.

Jonas

Hello, thank you :white_heart:. I am trying to use TCP or UDP because I do not have access to Raspberry Pi at this time.

I haven’t tried this variant myself, but it looks quite straightforward:

(It is for ESP8266.)

I guess, saying guess, you will have to look carefully on the IP addresses being used.
There is always a risk there will be conflicts with other devices and apps.

Good Luck!

1 Like

You can run Node-Red and Mosquitto on windows too.

Pete.

2 Likes

are you getting a value at all? just looked in your code and theres an error in your section where you check if data is in between 0-1200 or whatever value, u set the received data value to the boolean result so it will always be 1 or 0 not your sensor value. If not also be sure that your using an adc1 pin on the esp32 as the adc2 pins dont communicate with blynk protocols or most wifi protocals maybe esp now was the exception and you were able to see values but when connected to server the values were garbage.