It introduces how to connect the devices to a remote external server based on Mwifi
and Ethernet
module APIs. To be specific, the devices transmit all the data to the root node via ESP-MESH, and then the root node connects to a remote server with LWIP.
This example implements the functions of sending device data to a TCP server or sending data to a specific node or a specific group of nodes from a TCP server over the mesh network.
- At least 2 x ESP32 development boards( One need support ethernet connection, the other need run "no_router" example in
Non-Root device
mode. Both of then should use same Mesh ID and channel ) - 1 x router that supports ethernet
- Connect PC or the mobile phone to the router.
- Use a TCP testing tool (any third-party TCP testing software) to create a TCP server.
Note: This example uses the iOS TCP_UDP tool.
Enter make menuconfig
, and configure the followings under the submenu "Example Configuration".
- ESP-MESH network: The network password length should be between 8 and 64 bits (both exclusive), and the network will not be encrypted if you leave the password blank.
- TCP server: the information of the TCP server run on the PC
Configure the followings under the submenu "Example Configuration->Eth-helper`.The configuration of Eth-helper is defined by the connection of PHY chip and ESP32. You can read example of ethernet in the ESP-IDF.
Make:
make erase_flash flash -j5 monitor ESPBAUD=921600 ESPPORT=/dev/ttyUSB0
CMake:
idf.py erase_flash flash monitor-b 921600 -p /dev/ttyUSB0
- ESP-MESH devices send the real-time device status to the TCP server at an interval of three seconds.
- The TCP server sends data (in as format describe in the following section) to a specific address or group address:
- When the destination address is
ff:ff:ff:ff:ff:ff
, it will send data to all devices. - When the destination is a group address, it will send data to all the devices in this group.
- When the destination address is
The data format for TCP server communication:
{"dest_addr":"dest mac address","data":"content"}
{"group":"group address","data":"content"}
For Example:
{"dest_addr":"24:0a:c4:08:54:80","data":"Hello ESP-MDF!"}
{"group":"01:00:5e:ae:ae:ae","data":"Hello ESP-MDF!"}