Multiple Esp32 Communication

0 views
Skip to first unread message

Jacquelyne Betance

unread,
Aug 5, 2024, 4:29:06 AM8/5/24
to dropsasearchma
Thistutorial shows how to set up an ESP32 board to receive data from multiple ESP32 boards via ESP-NOW communication protocol (many-to-one configuration). This configuration is ideal if you want to collect data from several sensors nodes into one ESP32 board. The boards will be programmed using Arduino IDE.

Upload the following code to your ESP32 receiver board. The code is prepared to receive data from three different boards. You can easily modify the code to receive data from a different number of boards.


To use Wi-Fi to create a web server and use ESP-NOW simultaneously, you need to set up the ESP32 both as a Wi-Fi station and access point. Additionally, you need to set a different Wi-Fi channel: one for ESP-NOW and the other for the station. You can follow the next tutorial:


Hi Rui, great tutorial again I will try it soon ?

I was wondering if it would be possible to synchronize all boards to go to deep sleep in between communications (say sleep 15 minutes, everyone wakes up and sends sensor readings to the receiver, everyone sleep again). Would you have an option for that (maybe synchronizing time between boards)? The goal being to save battery when constant sensor readings are not required. Thanks again for all these great tutorials which are clearly explained!


If something follows a fixed scheme it is pre-destinated to be done by a computer.

Mac-adresses and writing code is such a thing. So I wrote a function that prints out the mac-adress in a way that produces the code-line for defining the mac-adress with all details except the variable-name


Hello, First thank you for all the information shared with everyone.

I tried to do with the esp826 the programming that you did with the esp32 (several esp32 which send data to an Esp32, in fact temperature and humidity as well as the ID of the board). There is a part of the code where I hang, it is the structure. I managed to display the id but the temperature and humidity is 0. On the other hand with an esp8266 can send to another esp8266 the id., Temperature and humidity without problem. So I send you the transmitter and receiver program. the transmitter is an esp01 and the receiver is a wemos d1 r1. I also send you the result received from the receiver on the serial port.


The structures of sender and receiver deviate from each other

you are using a variable of type String in the structure (very bad idea)

the memcopy-command copies too less bytes

the send_ESP_Now-message sends too less bytes


This comment-section is not well suited for such discussions and support.

Sorry Rui and Sara: if you keep this simple comment-function I will repeat to suggest asking the questions in the arduino-forum.


Hi Sara,

Can I use ESP-NOW to send data from one ESP8266 and one ESP32 to an ESP8266 (receiver) ? I have that need. It should work because the commands are all the same regardless of bard type, are they not?

Please let me know.

Thank you

Mike


Respected Sara Santo , You have done great work. Still I have one doubt regarding Multiple transmitters and single receiver that>>>>>> I am getting the data from all transmitters with their ID. But want to receive data sequentially. How to obtain data coming from 3 transmitter sequentially? Thanks.


HI

I am hoping to use a few ESP01s modules to capture temp from either BME280 or BS18D20 sensors on a Beehive. I want to use them as they are extremly small. I hope to power them with a disc battery. Could I use them in a ESP NOW many to one with a dev module and the one.

Would this work do you think?


Hi Sara, I had the same issue in the broadcast tutorial code ( -now-one-to-many-esp32-esp8266/) and doing this fix helped me there as well. Just wanted to let you know in case you want to update that tutorial as well. ?


Hi,

I have a question: What will happen when the process time, in the OnDataRecv of the receiver, is longer then the rate of messages arrival from 20 sending stations? will messages be lost? be queued ? will the sender be notified that the receiver is busy?

Thanks


Hello Rui and Sara,

Thank you for sharing this interesting tutorial.

I have successifully tried to repeat it at my home, but i woul like to add something.

I tried to send data of Temperature and Humidity collected by two devices to a database using post.

Unfortunately i noticed that i am able to collect the results of both, but when it comes to connect to WiFi for sending post data i fail to connect.

Do you know if there are some triks to overcome this issue?

Thank you very much

Regards

Manuel


so i looked at this code (esp32) and esp8266 many to one implementation. And now i have a question are these two libraries different? espnow.h and esp_now.h or the same.

When i try to flash code with esp_now it says ERROR.


I am planning to build a system og ESP32 like descibed here.

The sensors are temperature measuring. The sensors Will be placed in different buildings.

But I allready have a wifi network covering all buildings.

My question:

Will the system work on the existing wifi network?


Hello Sara,

Is it possible to use the ESP Now method to send data from multiple platforms (sensors) to a receiver that is setup as websocket server so that I am able to access to all sensor data via internet? Or how can this be done? Thank you.


Hi Sara Santos can you please tell me is same thing possible with BLE esp32(many to one communication) if yes can you please guide me with some reference. For my project I need many to one commuincation using ble.


I am sending data from a transmitter to a single receiver using ESP-NOW. At the receiver side, i am serial printing the received data at a baud rate of 115200.

everything works fine. I have observed one thing.

The problem is when i switch off the power at the transmitter side, it takes around a second to have a no data at the receiver serial monitor. I know that the buffer gets be cleared till it stops showing any data at the receiver


Thank you for all the great articles!

In the many to one example, I replaced the struct x,y variables with float variables to work with temp/ humidity readings from 2 sht45 sensors. And in the receiver sketch I printed results on a ssd1306 oled. Everything displays, but the display alternates the readings. How do you get readings from different sensors on different lines without the readings alternating. Would like to have 4 lines temp1/hum1/temp2 /hum2, without them alternating. Thank you


Hello Sara

Thanks for the reply back. Would like to show both id 1and id 2 to remain on the oled screen constantly but with updated temp/hum readings to be updated every 10 seconds that the sender sketch is set at. Kind of like the Esp now Web server example where only the temp/hum readings are being updated, but the id names never change.Thank you


Affiliate Disclosure: Random Nerd Tutorials is a participant in affiliate advertising programs designed to provide a means for us to earn fees by linking to Amazon, eBay, AliExpress, and other sites. We might be compensated for referring traffic and business to these companies.


In this tutorial, we will see how to send data from multiple ESP32 boards to a single ESP32 using ESP-NOW and Arduino IDE. In other words, we will transmit data from many ESP32 to one ESP32 board (Many to One Communication). Previously, we sent data from one ESP32 to another ESP32 and from one ESP32 to many ESP32 boards (One to Many Communication) via ESP NOW one way communication. Additionally, we also transmitted sensor readings between two ESP32 boards and displayed the readings on an OLED display via ESP-NOW two-way communication.


This protocol is a low-power, secure, and direct wireless communication protocol that enables multiple ESP32 devices to communicate with each other without the need for Wi-Fi or a router. Using ESP-NOW, we can perform one-way and even two-way communication between ESP MCU devices without using a Wi-Fi network.


As you can view in the picture below, one ESP32 board act as the sender and the other board receives the data and hence acts as the receiver.

Uses: Sending sensor data, controlling ESP outputs including LEDs, relays, buzzers, etc.


This project consists of four ESP32 boards where one will act as the receiver (slave) and the other three will be the senders(masters). Our aim will be to show you how to receive data from the three sender ESP32 boards by the receiver ESP32 board. First, we will find the MAC address of of the receiver ESP32 board. Then, after programming the boards with their respective sender and receiver sketches, receiver board will start receiving data from the sender ESP32 boards through ESP-NOW protocol.


To identify each sender board on the receiver side we will associate an ID for each sender board. For example, the first sender board will have ID=1, the second sender board will have ID=2 and the third sender board will have ID=3. For testing purposes we will send a random integer from 0-20 with the respective ID of the sender board.


We will use Arduino IDE to program our ESP32 development board. Thus, you should have the latest version of Arduino IDE. Additionally, you also need to install the ESP32 plugin. If your IDE does not have the plugin installed you can visit the link below:


Make sure you choose the correct board and COM port before uploading your code to the board. Go to Tools > Board and select your board. Next, go to Tools > Port and select the appropriate port through which your board is connected. In this case, we are using the ESP32 development board which is connected to COM5.


Now, let us learn how to send data from many ESP32 boards to a single ESP32, using the ESP-NOW protocol. We will use the many-to-one configuration, where multiple ESP32 boards act as the sender and one ESP32 board acts as a receiver. You can use the method given below to transmit sensor data or any type of information from one ESP board to another. For this project, we will require two Arduino sketches one for the senders and the other for the receiver.

3a8082e126
Reply all
Reply to author
Forward
0 new messages