Old Macdonald - Decentralised Controlled Environment Agriculture System Help

Orchestrator

Overview

This chapter describes the development of the Orchestrator device which facilitates system automation through the following processes:

  • Establishing network infrastructure by creating and managing Thread networks and Matter Fabrics.

  • Commissioning devices to join Matter fabrics and Thread networks

  • Monitoring sensor data from the Grow Chamber and adjusting actuators in real time.

Prerequisites:

Development

Project Bootstrap

The following steps from ESP32 Project Workflow guide are required to bootstrap the project:

Project Build Configuration

Configure the build process by updating the CMakeLists.txt. It should include the following:

  • ESP_MATTER_PATH and MATTER_SDK_PATH environment variables integrate ESP-Matter and Matter SDK.

  • ESP_MATTER_DEVICE_PATH points to the correct hardware HAL.

  • EXTRA_COMPONENT_DIRS includes component directories for ESP-Matter, SDK, and device HAL.

  • Essential CMake files from IDF and ESP Matter Device must be included before any IDF_TARGET references.

  • Compiler flags that add C++17, optimizations, Matter defines, disable Thread driver, and suppress RISCV warnings.

Project Default Configuration

The sdkconfig.defaults file is used to specify default configuration settings:

  • Set Flash size to 8MB

  • Enable Wi-Fi station mode only.

  • Enable OpenThread with a Border Router.

  • Configure IPv6 support for OpenThread (LwIP).

  • Enable ESP32 BLE Controller.

  • Enable Bluetooth with NimBLE stack.

  • Use a custom partition table from partitions.csv.

  • Enable the CHIP shell for Matter.

  • Enable Matter Controller, disable the server and commissioner features.

  • Disable OTA Requestor and route hook.

  • Enable WebSocket server support.

Custom partition table

CONFIG_PARTITION_TABLE_CUSTOM=y and CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" in sdkconfig.defaults enable a custom partition table defined in partitions.csv:

  • nvs (24 KB) stores persistent key-value data

  • phy_init (4 KB) holds PHY calibration settings

  • factory (3 MB) contains the main application firmware.

  • rcp_fw stores firmware updates for the Radio Co-Processor (RCP).

System Initialization

The main function initializes the essential components:

  • ESP NVS library stores key-value pairs in the device’s flash memory.

  • ESP Event Loop Library lets components publish events indicating important occurrences, such as a successful Wi-Fi connection to the event loop, while other components can register handlers to respond. This decouples event producers from consumers, allowing components to react to state changes without direct application involvement.

  • ESP-NETIF library is an abstraction layer that provides thread-safe APIs for managing network interfaces on top of a TCP/IP stack.

  • Components

Last modified: 17 May 2025