Close

Log4:UART+ESP-MESH

A project log for Swarmesh NYU Shanghai

Scalable swarm robot platform using ESP32 MESH capabilities and custom IR location

zander-maoZander Mao 06/15/2019 at 03:190 Comments

Introduction:

This log is based on the experiments on ESP-MESH with UART from June 11 to June 15 using esp32. Since other devices cannot directly communicate with the nodes in the mesh, It will be very easy for us to manage the swarm if we can directly control one esp32 with UART and use it to join the group.

Method:

The test is based on two example project of esp-idf: peripherals/uart/uart_echo &  mesh/interal_communication. We use a Producer/Consumer model to link them together. 

For the station, The idea is to establish two message queues, one for mesh send and another for mesh receive. Every time an esp32 receives a message from UART, it will put it in the mesh send queue. Another task will listen to the queue, once there is an item in the queue, the mesh send task will dequeue it and send it to the mesh network. Vice versa, once the station receives a message from the mesh network, it will send the message to the uart receive queue. Once the UART receive task detects that there's an item in the mesh receive queue, it will send it back to computer through UART. Thus we have an asynchronous duplex communication with the mesh network.


For the robot, right now it just receive the message and respond to the station.

Coding Detail:

The data pack size sent through the mesh network is defined at the beginning of the code:

If the size of the data is too big, the latency will be high.

For the task to listen to the queue forever, the third parameter in the xQueueReceive() function should be set to portMAX_DEALY. If set to 0, it'll return immediately if the queue is empty.

Test code can be found here:
Mesh Station:
https://github.com/Zander-M/NYUSH_DURF_2019_SWARM_ROBOTS/tree/master/Project/Code/MESH_STATION
Mesh Robot:
https://github.com/Zander-M/NYUSH_DURF_2019_SWARM_ROBOTS/tree/master/Project/Code/MESH_ROBOT
 


Discussions