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:
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:
- There is a master node listening on address 2
- If I add a new node
A
to the network it listens on address 1. - Master discovers all devices that have address 1 every few seconds.
- So eventually node
A
receives a discovery packet message that comes from master. NodeA
listens now on a random address and replies to master with that random anddress. - 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?