Skip to main content
edited tags
Link
Tono Nam
  • 986
  • 1
  • 10
  • 22
Source Link
Tono Nam
  • 986
  • 1
  • 10
  • 22

ESP32 send data to another ESP32 without establishing a wifi connection

Originally I was creating a project consisting of the Atmega328P and NRF24L01 to create multiple arduinos that could talk to each other. Basically I was creating something like this:

enter image description here

As the network grows I am starting to run out of memory when using the atmega328P. I have to be careful about allocating memory and more. So I will like to replace the NRF24L01 with the ESP32. The price of the ESP-WROOM-32 by itself is also cheaper than buying an NRF24L01 + the atmega328.


Question

How can I send data from one ESP32 to another ESP32 without establishing a WiFi connection? Just like the NRF24L01 where you specify a writting pipe where you want to send the data and the other NRF24L01 is listening on that pipe.


I know I can do that with ESP-NOW. This video explains how. The problem with ESP NOW is that I have to know in advance the mac address of the ESP32 where I intend to send a message. I plan to be able to keep adding smart home devices without having to know the mac address.

My algorithm with NRF24 that I already created is as follows:

  1. There is a master node listening on address 2
  2. If I add a new node A to the network it listens on address 1.
  3. Master discovers all devices that have address 1 every few seconds.
  4. So eventually node A receives a discovery packet message that comes from master. Node A listens now on a random address and replies to master with that random anddress.
  5. So node A is now connected to the network.

The cool thing about this algorithm is that I can keep adding new nodes to the network without knowing in advance its address. I will like to do the same thing with the ESP32. How can I send a simple message betweenn 2 ESP32 modules?