Introduction to ESP-Mesh-Lite Solution
Note
This document is automatically translated using AI. Please excuse any detailed errors. The official English version is still in progress.
Overview of ESP-Mesh-Lite Solution
ESP-Mesh-Lite is a Mesh solution built on the Wi-Fi protocol, based on the SoftAP + Station mode, and modeled after IoT-Bridge. ESP-Mesh-Lite allows a large number of devices distributed over a wide area (both indoors and outdoors) to connect with each other within the same WLAN (Wireless Local Area Network). The advantages of this solution are as follows:
ESP-Mesh-Lite is a network structure different from traditional Wi-Fi networks. In the ESP-Mesh-Lite network, nodes do not need to connect to a central node, but can directly connect with neighboring nodes. This interconnection between nodes allows for a wider network coverage area, unrestricted by the distance to the central node.
Traditional Wi-Fi networks usually adopt a centralized structure, where all nodes connect to a central node (such as a router). This network structure may cause the central node to be capacity-limited, affecting the scalability and stability of the network. However, in the ESP-Mesh-Lite network, nodes are interconnected, allowing nodes in the network to be responsible for data forwarding of neighboring nodes, no longer limited by the capacity of the central node.
Since each node in the ESP-Mesh-Lite network is assigned an IP address by the parent node, nodes can access the network as if they were individual devices connected to a router. The transmission of information is imperceptible to the parent node, greatly reducing the difficulty of application layer development.
In summary, the ESP-Mesh-Lite network has a tree-like network structure, strong scalability, wide coverage, interconnected nodes, and increased network flexibility. Compared with traditional Wi-Fi networks, ESP-Mesh-Lite has greater advantages and applicability in IoT applications.
Common Application Scenarios of ESP-Mesh-Lite
Smart home control systems: Due to the interconnection between nodes, smart devices can communicate directly with neighboring devices, improving response speed and stability.
Smart agriculture: Many wireless sensors in the fields need to communicate with each other and send messages to the cloud.
Photovoltaic inverters: Upload collector data to the cloud.
Smart lighting: Group control and group control of lights and data reporting.
Environmental monitoring: Can achieve data collection and transmission of multiple environmental monitoring devices, providing more comprehensive environmental data.
Education and training: Connect multiple teaching devices and student terminals to achieve sharing and interaction of teaching resources.
Smart security: Multiple security devices can achieve data sharing and linkage control, improving the response speed and reliability of the security system.
Remote device management: Perform OTA firmware upgrades for all devices in the network.
Reference Materials for Getting Started with ESP-Mesh-Lite
ESP-Mesh-Lite SDK:
ESP-Mesh-Lite Solution Guide Document: (Must-read, provides an introduction to the ESP-Mesh-Lite protocol)
ESP-Mesh-Lite Basic Example Link: (It is recommended for developers to run this example to simply understand the basic usage of ESP-Mesh-Lite and related APIs)
ESP-Mesh-Lite + Rainmaker Example Link: (Includes provision, LAN OTA, Mesh node communication and other advanced usage)
ESP-Mesh-Lite Component Manager Link:
How to Enable ESP-Mesh-Lite
Enabling ESP-Mesh-Lite is very convenient, developers only need to simply call some API commands to enable ESP-Mesh-Lite. Refer to the mesh_local_control example:
Initialize the NVS partition of ESP32 to save configuration information.
Initialize the network interface. Call the esp_netif_init() function.
Create the default event loop. Call the esp_event_loop_create_default() function.
Create all network interfaces, including STA mode and SoftAP mode. Call the esp_bridge_create_all_netif() function.
Initialize Wi-Fi functions, including initializing Wi-Fi’s STA mode and SoftAP mode, first connect to the specified Wi-Fi hotspot (STA mode), and then open the SoftAP hotspot (SoftAP mode). When connecting to Wi-Fi and opening SoftAP, try to read the previously saved configuration from NVS. If the reading fails, use the predefined default value.
Station:
Define a wifi_config_t structure variable wifi_config to configure the parameters of Wi-Fi’s STA mode.
Set the ssid (Wi-Fi hotspot name) and password (Wi-Fi hotspot password) of wifi_config.sta.
Set the Wi-Fi mode to STA mode, and use wifi_config.sta.ssid and wifi_config.sta.password as parameters to connect to the specified Wi-Fi hotspot. The fourth parameter is NULL, indicating that no callback function is set. Call the esp_bridge_wifi_set function.
SoftAP:
Clear the content of the wifi_config structure to prepare for the configuration of SoftAP mode below.
Define a variable to store the SSID length in SoftAP mode.
Get the SSID in SoftAP mode from NVS. If the acquisition fails, use the default value defined by the CONFIG_BRIDGE_SOFTAP_SSID macro. Call the esp_mesh_lite_get_softap_ssid_from_nvs function.
Define a variable to store the password length in SoftAP mode.
Get the password in SoftAP mode from NVS. If the acquisition fails, use the default value defined by the CONFIG_BRIDGE_SOFTAP_PASSWORD macro. Call the esp_mesh_lite_get_softap_psw_from_nvs function.
Set the Wi-Fi mode to SoftAP mode, and use wifi_config.ap.ssid and wifi_config.ap.password as parameters to open the SoftAP hotspot. The fourth parameter is NULL, indicating that no callback function is set. Call the esp_bridge_wifi_set function.
Provide default values for Mesh network configuration. Define the esp_mesh_lite_config_t structure variable and initialize it with the ESP_MESH_LITE_DEFAULT_INIT() macro.
Initialize ESP-Mesh-Lite and start the Mesh-Lite network. Call the esp_mesh_lite_init() function and configure it with the structure defined in the previous step.