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:
- 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.
- 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