Figuring out the right WiFi protocol

Since thursday I’ve looked into how to implement the wifi communication we need between our phyllos (see Ruling the colony of Phyllos ).
We need a way for multiple Phyllos next together to broadcast data between themselves, and a way to communicate with the Phyllos from a smartphone or computer (for instance), and we will be using a ESP32 dev kit C integrated in our Phyllos.

Data exchange between Phyllos

The rate at which the phyllo need to exchange data doesn’t have to be very high at all: we just want to exchange small messages such as “Here is my ID: xxxx” , or “Start animation X at time T”. We first thought about turning the Phyllo with the smallest ID into an access point to which all Phyllos would connect, but if there is a failure with that specific Phyllo the whole communication between all the phyllos fail, and we wanted something more reliable that didn’t depend on a Phyllo.

Our first idea was to have all the Phyllos connect to an external access point. I looked into that, and saw that it should be pretty easy to do using UDP, especially since the ESP32 documentation is well written and there are multiple code examples.

I also tried to search for a way to connect the Phyllos without having to rely on an external network, and found that ESP32 have a mode called “ESPnow” which enables multiple ESP32 to communicate between them without using any access point.

Communicating with the Phyllos

To communicate to a Phyllo from a computer or smartphone, we can simply connect to the same access point our Phyllos are connected on and use UDP. This would be useful for example to transfer custom animations to a Phyllo.

However, if we use ESPnow we are not sure we can have the ESP32 connect to an access point at the same time. And even if we can, the need to connect to an access point anyway reduces the usefulness of ESPnow.CommunicatingHowever, if we use ESPnow we are not sure we can have the ESP32 connect to an access point at the same time. And even if we can, the need to connect to an access point anyway reduces the usefulness of ESPnow.

There is one case left : If we turn on a Phyllo and it cannot connect to an access point (either because we moved it or we haven’t yet told him an access point’s SSID it can use), the Phyllo should become an access point, allowing a computer or smartphone to connect to it and help it connect to an access point using UDP.

Another use of UDP

Alexis suggested to us Friday we might be able to use UDP broadcast to transmit a common time reference on all the Phyllos. We will test this very soon as we have already ordered multiple ESP32, but if a packet broadcasted by UDP gets sent to everyone at the same time (it would physically make sense since wifi uses waves), then all the Phyllos could use the packet arrival time to get a common time reference with as much precision as with our previous method with IR.

If the tests are successfuls, we will drop the IR recievers planned specifically for time reference transmission from the PCBs. We will keep you updated.

Leave a Reply

Your email address will not be published. Required fields are marked *