Comments on: ESP-NOW with ESP32: Receive Data from Multiple Boards (many-to-one) https://randomnerdtutorials.com/esp-now-many-to-one-esp32/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Wed, 26 Feb 2025 15:04:27 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Lee https://randomnerdtutorials.com/esp-now-many-to-one-esp32/#comment-1011260 Wed, 26 Feb 2025 15:04:27 +0000 https://randomnerdtutorials.com/?p=96216#comment-1011260 In reply to Sara Santos.

I’m working on something like this right now. The hard part of it is if you want to have an expanded wireless range that requires each mesh node to pass messages along to the main “controller”. For the first 60 seconds after starting up the controller stores the unique nodeIDs from any incoming messages in an array. We need that so that we can wait for an update from each “data sender” before we broadcast a “sleep” message to them.
My data sender nodes are sending the battery voltage and temperature readings.
When we have an update from all nodes we broadcast a sleep message with the duration (so I can change that from the controller).
When the data sender nodes receive that message they do 2 mesh.update(); calls to try to make sure all nodes get the message.

Here’s what I have so far in the controller’s receivedCallback

void receivedCallback( uint32_t from, String &msg ) {
Serial.printf("Received from %u msg=%s\n", from, msg.c_str());
JSONVar myObject = JSON.parse(msg.c_str());
bool found = false;
for (int i = 0; i < nodeCount; i++) {
if (from == nodeIDs[i][0]) {
if (nodeIDs[i][1] == 0) {
nodeIDs[i][1] = 1;
updateCount++;
}
found = true;
}
}
if (found == false) {
nodeIDs[nodeCount][0] = from;
nodeIDs[nodeCount][1] = 1;
nodeCount++;
updateCount++;
Serial.println("Found new node");
}

// TODO: Alert if a temperature reading is too high!
// TODO: Alert if a battery voltage is getting too low

if ((millis() - startTimestamp) > (initialWaitSec * 1000)) {
if (updateCount == nodeCount) {
Serial.println("sending sleep");
JSONVar jsonReadings;
jsonReadings["sleep"] = sleepSeconds;
readings = JSON.stringify(jsonReadings);
mesh.sendBroadcast(readings);
// reset all nodes to unreceived
for (int i = 0; i < nodeCount; i++) {
nodeIDs[i][1] = 0;
}
updateCount = 0;
}
}

// TODO: Add a watchdog timer to alert if a node stops responding

}

]]>
By: Sara Santos https://randomnerdtutorials.com/esp-now-many-to-one-esp32/#comment-1003171 Mon, 27 Jan 2025 18:13:40 +0000 https://randomnerdtutorials.com/?p=96216#comment-1003171 In reply to Christian.

Hi.
I don’t think that would be a problem.
But, if you want to make sure it receives all readings, maybe it’s better to send an acknowledged message from the receiver to the sender.

Regards,
Sara

]]>
By: Christian https://randomnerdtutorials.com/esp-now-many-to-one-esp32/#comment-1003153 Mon, 27 Jan 2025 16:01:45 +0000 https://randomnerdtutorials.com/?p=96216#comment-1003153 Hi Sara, hi Rui,
I have several sensors (ESP32 boards) that send data to a receiver. I understand from your blog entry that this could never lead to a problem if two sensors send data at the same time?

Thank you so much for your great work! I love randomnerdtutorials 🙂

]]>
By: Shelley https://randomnerdtutorials.com/esp-now-many-to-one-esp32/#comment-959287 Thu, 19 Sep 2024 04:37:56 +0000 https://randomnerdtutorials.com/?p=96216#comment-959287 Hi Sara
How would I send different Data from the Master to the Slave, using struct or typedef? master 1 would send [ id, x, y ] but master 2 would send [ id, speed, temp, x, y, ] and master 3 would send [ id, x, y, hight, time ]. Maybe a struct array or something? I don’t see the use of sending the same Data from 3 different places, But different Data would be very useful. Can this be done?
Thanks Shelley

]]>
By: Sara Santos https://randomnerdtutorials.com/esp-now-many-to-one-esp32/#comment-924310 Tue, 11 Jun 2024 16:53:42 +0000 https://randomnerdtutorials.com/?p=96216#comment-924310 In reply to Roberto.

It is now updated and compatible with 3.0.0.
Regards,
Sara

]]>
By: mitesh shah https://randomnerdtutorials.com/esp-now-many-to-one-esp32/#comment-923778 Mon, 10 Jun 2024 16:08:01 +0000 https://randomnerdtutorials.com/?p=96216#comment-923778 Hi
Basically i want, to Disable receiving data from sender for some time,
will try using , >> esp_now_unregister_recv_cb()
but its not working

]]>
By: mitesh shah https://randomnerdtutorials.com/esp-now-many-to-one-esp32/#comment-923764 Mon, 10 Jun 2024 15:34:23 +0000 https://randomnerdtutorials.com/?p=96216#comment-923764 Hi
How Deseble data receiving ?
will try using , >> esp_now_unregister_recv_cb()

]]>
By: Roberto https://randomnerdtutorials.com/esp-now-many-to-one-esp32/#comment-917496 Thu, 23 May 2024 06:37:47 +0000 https://randomnerdtutorials.com/?p=96216#comment-917496 In reply to Carlos.

Carlo I had the same issue and now solved I’ve solved ,
I was using in arduino ide the board definition 3.0.0 -rc that seems to be not compatible with the intruction format “esp_now_register_recv_cb(OnDataRecv);”.
I’ve installed the version 2.0.14 and now is working.

Should be great update the code for the new board version or place an allert in the comments.

]]>
By: Roberto https://randomnerdtutorials.com/esp-now-many-to-one-esp32/#comment-917382 Wed, 22 May 2024 20:03:25 +0000 https://randomnerdtutorials.com/?p=96216#comment-917382 Hi Sara. I use this code for my ESP32-C3 mini .
No problem when i compile the sender but with the receive I’ve the same error mentioned by Carlos in November , see some post above :

exit status 1

Compilation error: invalid conversion from ‘void ()(const uint8_t, const uint8_t*, int)’ {aka ‘void ()(const unsigned char, const unsigned char*, int)’} to ‘esp_now_recv_cb_t’ {aka ‘void ()(const esp_now_recv_info, const unsigned char*, int)’} [-fpermissive]

Have you idea if there is any issues with such levels of libraries ?
Thanks Roberto

]]>
By: seth https://randomnerdtutorials.com/esp-now-many-to-one-esp32/#comment-915534 Wed, 15 May 2024 12:32:01 +0000 https://randomnerdtutorials.com/?p=96216#comment-915534 In reply to seth.

as an example, when i do the many to one version; i will often get the readings in an incorrect order… i thought the data structure would force them to come out on receiver as board1, board 2, board 3.

However it seems kind of random, one time if i boot them up (all at same time because power hub being used) i’ll get like: board2, board3, board1… is there a way to force them into ascending order based on the id?

]]>