How leafai-io/leaf-node-v3.x works
Leaf Node is ESP32-S3 environmental monitoring and control firmware. Its principal workflow provisions Wi-Fi and MQTT settings over BLE, reads configured sensors across supported buses, publishes telemetry and heartbeats, and accepts commands that control outputs or configure schedules. The graph also preserves the documented OTA, UART node-chain, factory setup, and health-monitoring capabilities. Relationship evidence is limited to the README, SOURCE INDEX references, and supplied excerpts; unverified wiring is omitted rather than inferred.
Main entry points: LeafNode.cpp Node orchestration · SensorManager.cpp Sensor orchestration · ScheduleManager.cpp Output schedules · OTAManager.cpp Firmware updates
Components 28
Provisioning and runtime
- Firmware entry
firmware/src/main.cpp - Node orchestration
firmware/src/LeafNode.cpp - BLE provisioning
firmware/src/network/BLEConfigManager.cpp - Persistent configuration
firmware/src/runtime/RuntimeConfig.cpp - Factory console
firmware/src/diagnostics/SerialCommandHandler.cpp
Sensor acquisition
- Sensor orchestration
firmware/src/sensors/SensorManager.cpp - Sensor drivers
firmware/src/hardware/sensors - RS485 bus
firmware/src/hardware/RS485Manager.cpp - SDI-12 bus
firmware/src/hardware/SDI12Manager.cpp - OneWire bus
firmware/src/hardware/OneWireManager.cpp
Networking and messaging
- Wi-Fi connectivity
firmware/src/network/WiFiManager.cpp - MQTT messaging
firmware/src/network/MQTTManager.cpp - Sensor telemetry
firmware/src/network/MQTTSensorPublisher.cpp - Actuator status
firmware/src/network/ActuatorStatusPublisher.cpp - UART node chain
firmware/src/network/UARTChainManager.cpp - Web interface
firmware/src/network/WebServerManager.cpp
Control and scheduling
- Command handling
firmware/src/core/CommandHandler.cpp - Actuator outputs
firmware/src/hardware/Actuator.cpp - DAC output
firmware/src/hardware/MCP4725.cpp - PWM outputs
firmware/src/hardware/PWMController.cpp - Output schedules
firmware/src/system/ScheduleManager.cpp
System operations
- Firmware updates
firmware/src/network/OTAManager.cpp - Periodic tasks
firmware/src/core/TaskManager.cpp - Health and status
firmware/src/system/SystemManager.cpp - Diagnostics logging
firmware/src/diagnostics/Logger.cpp
Other components
- Leaf AI app
- Environment sensors
- MQTT service
Connections 35
- Firmware entry → Node orchestration: starts
firmware/src/main.cpp - Leaf AI app → BLE provisioning: provisions
README.md - BLE provisioning → Persistent configuration: saves settings
- Persistent configuration → Wi-Fi connectivity: provides credentials
- Node orchestration → BLE provisioning: initializes
- Node orchestration → Persistent configuration: uses
- Node orchestration → Sensor orchestration: coordinates
- Environment sensors → Sensor drivers: provides readings
README.md - Sensor orchestration → RS485 bus: uses
- Sensor orchestration → SDI-12 bus: uses
- Sensor orchestration → OneWire bus: uses
- Sensor orchestration → Sensor drivers: selects drivers
- Sensor orchestration → MQTT messaging: publishes readings
- Sensor orchestration → Sensor telemetry: publishes telemetry
- MQTT service → MQTT messaging: exchanges messages
README.md - MQTT messaging → Command handling: dispatches commands
- Command handling → Actuator outputs: controls outputs
- Output schedules → Actuator outputs: switches outputs
firmware/src/system/ScheduleManager.cpp - Output schedules → DAC output: sets values
firmware/src/system/ScheduleManager.cpp - Output schedules → PWM outputs: schedules outputs
firmware/src/system/ScheduleManager.cpp - Output schedules → Persistent configuration: reads configuration
firmware/src/system/ScheduleManager.cpp - Output schedules → Actuator status: publishes status
firmware/src/system/ScheduleManager.cpp - Leaf AI app → MQTT messaging: configures schedules
- Node orchestration → Firmware updates: initializes
- Firmware updates → Sensor orchestration: pauses sensors
firmware/src/network/OTAManager.cpp - Firmware updates → Periodic tasks: pauses tasks
firmware/src/network/OTAManager.cpp - Firmware updates → Health and status: updates status
firmware/src/network/OTAManager.cpp - Firmware updates → MQTT service: downloads firmware
- Node orchestration → UART node chain: initializes
- Node orchestration → Web interface: initializes
- Node orchestration → Factory console: initializes
- Node orchestration → Periodic tasks: uses
- Node orchestration → Health and status: uses
- Health and status → UART node chain: monitors
- Node orchestration → Diagnostics logging: uses