Post topics, source code that relate to the Arduino Platform

User avatar
By Anand Lobo
#43713 Here's the deal. I have a few ESP-12 modules, and this is an idea I thought would be fun but is currently annoying me.

I want to set them up in a mesh format where any one ESP module needs to connect to Wi-Fi to get the current NTP time using the example sketch, and broadcasts it via UDP on its internal softAP to other connected ESPs, which should repeat the process. Hopefully this 'visual' makes sense:

Wi-Fi <===> (wifi) ESP (AP) <===> (wifi) ESP (AP) <===> (wifi) ESP (AP) <===> etc

So basically a mesh of UDP packet repeaters, except every step that is repeated is a separate ESP softAP SSID (and an alternating IP range, to avoid collisions - so the home network would be 192.168.1.x, first AP hop would be 192.168.4.x, then 192.168.3.x, and repeat)

Now, we know that the NTP time sketch works so that's not an issue. In this case, I'm using just two of the ESP modules for this attempt.
I've written a subroutine based on the "WifiMesh" source code, where
1) ESP connects either to
... a) existing WiFi network, to get time from internet
... b) nearby ESP softAP, to get time via UDP
2) each ESP sets up its own softAP, to re-broadcast time once received
So all ESPs are in dual WiFi mode, following these parameters above.

ESPx1 connects to WiFi just fine (192.168.1.x), gets time, outputs it to Serial, and broadcasts the time (4 bytes) on its softAP (192.168.4.x) using UDP. I checked the packets using WireShark, I believe it seems to be working.
ESPx2 connects to ESPx1 softAP (192.168.4.x) and sets up its own softAP (192.168.3.x). But it does not seem to be receiving any packets at all on 192.168.4.x. I am annoyed.

Can someone outline a working example of sending/receiving UDP packets between 2 ESPs, for me to test out? Like, over the main Wi-Fi as well as across the softAP? If I can get such an example to work I think probably I'll find out what I'm doing wrong.

Thank you for your help.