====== BLE Mesh ====== To understand the concept of Bluetooth Low Energy Mesh, I attached a video showing the main principles. {{youtube>DbrN5ONz3O4? }} ===== Overview ===== Initially, the idea was to use [[..:ble:start|]] for communication between the [[..:start|]] and all other components. However, the project has evolved. With the implementation of day/night cycles for the LEDs, light-emitting devices (e.g., [[..:..:warnemuende:lighthouse:start|]]) need to respond to the time of day. Consequently, if the cycle transitions to evening, the lights should turn on automatically. This is not easily feasible with standard [[..:ble:start|]], as it would require iterating through all known devices in sequence to connect, switch, and disconnect. This approach does not scale well. Connecting to all devices simultaneously would hit a hardware limit of approx. 5-7 devices (depending on the [[hardware:esp32:s3:start|ESP32S3]]). Therefore, the new approach, which appears to be compatible with both [[hardware:esp32:start|]] and [[hardware:stm32:start|]], is Bluetooth Low Energy Mesh (BLE Mesh). ====== Planning ====== I ask some AI Agents to create a concept for this feature. This is the result of it. ===== Plan: BLE Mesh System with ESP32S3/H2 and Self-Discovery ===== A comprehensive BLE Mesh network with ESP32S3 as the control unit and ESP32H2 satellites, supporting global control, individual device control, control unit hot-swapping, and automatic device discovery. The system uses ESP-BLE-MESH based on the Zephyr stack with Vendor Models for extended functionality. ==== Steps ==== - **Establish Basic BLE Mesh Architecture** with ESP32S3 as Provisioner and ESP32H2 as Nodes using the [[https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/esp-ble-mesh/|esp_ble_mesh]] Framework * **Official Documentation**: [[https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/esp-ble-mesh/|ESP-BLE-MESH Programming Guide]] * **API Reference**: [[https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/bluetooth/esp_ble_mesh.html|ESP-BLE-MESH API Reference]] * **Example Code**: [[https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh|ESP-IDF BLE Mesh Examples]] * **Provisioner Walkthrough**: [[https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh/provisioner|BLE Mesh Provisioner Example]] - **Implement Vendor Models** for Self-Description with Device Name, Capabilities, and Sensor Types in ''device_capability_t'' structure * **Vendor Model Guide**: [[https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh/vendor_models|ESP-IDF Vendor Model Example]] * **Custom Model Tutorial**: [[https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/esp-ble-mesh/ble-mesh-models.html|BLE Mesh Model Development Guide]] * **Bluetooth SIG Mesh Specification**: [[https://www.bluetooth.com/specifications/specs/mesh-profile-1-0-1/|Bluetooth Mesh Profile Specification]] - **Create Group Address System** for global commands (e.g., "Lights off") and individual Unicast addresses for specific devices * **Addressing Guide**: [[https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/esp-ble-mesh/ble-mesh-architecture.html#addressing|BLE Mesh Addressing Architecture]] * **OnOff Model Example**: [[https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh/onoff_models|Generic OnOff Server/Client]] * **Configuration Client**: [[https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh/provisioner|Config Model Implementation]] - **Develop Network State Persistence** with NVS Storage for NetKeys, AppKeys, and Node Database for Hot-Swapping support * **NVS Storage Guide**: [[https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/storage/nvs_flash.html|ESP-IDF Non-Volatile Storage]] * **BLE Mesh Storage**: [[https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/esp-ble-mesh/ble-mesh-architecture.html#mesh-stack-initialization|ESP-BLE-MESH Storage Documentation]] * **Key Management**: [[https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/esp-ble-mesh/ble-mesh-security.html|BLE Mesh Security Guide]] - **Implement Dynamic Discovery Service** with automatic Capability Detection and Self-Registration of new H2 Nodes * **Fast Provisioning**: [[https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh/fast_provisioning|ESP-BLE-MESH Fast Provisioning]] * **Remote Provisioning**: [[https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh/remote_provisioning|BLE Mesh v1.1 Remote Provisioning]] * **Sensor Models**: [[https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh/sensor_models|Sensor Server/Client Examples]] ==== Further Considerations ==== - **Backup Controller Strategy**: Primary/Secondary S3 with Heartbeat Monitoring or Network State Backup/Restore mechanism? * **Health Model**: [[https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/esp-ble-mesh/ble-mesh-models.html#health-server-model|BLE Mesh Health Server/Client]] * **Heartbeat Messages**: [[https://www.bluetooth.com/blog/bluetooth-mesh-heartbeat-messages/|BLE Mesh Heartbeat Guide]] - **Capability Advertisement Timing**: Periodic Broadcasts vs. On-Demand Requests for Node Capabilities and Names? * **Publication/Subscription**: [[https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/esp-ble-mesh/ble-mesh-models.html#model-publication|BLE Mesh Publication Model]] * **Network Performance**: [[https://www.bluetooth.com/blog/bluetooth-mesh-performance-optimization/|BLE Mesh Performance Optimization]] ==== Additional Resources ==== === Video Tutorials (YouTube Search) === * "ESP32 BLE Mesh tutorial" * "ESP-IDF BLE Mesh implementation" * "ESP32 mesh networking examples" * "Espressif BLE Mesh provisioning" === Advanced Documentation === * **WiFi Coexistence**: [[https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh/wifi_coexist|BLE Mesh + WiFi Example]] * **Directed Forwarding**: [[https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh/directed_forwarding|BLE Mesh v1.1 Features]] * **ESP32-H2 Specifications**: [[https://www.espressif.com/sites/default/files/documentation/esp32-h2_technical_reference_manual_en.pdf|ESP32-H2 Technical Reference Manual]] * **ESP32-S3 Features**: [[https://www.espressif.com/sites/default/files/documentation/esp32-s3_datasheet_en.pdf|ESP32-S3 Series Datasheet]]