CeresFlows Firmware Protocol — Overview

This guide explains how to build firmware that communicates with the CeresFlows automation backend. By the end of this series, you will understand every command, every response format, and every board-specific difference — enough to write a fully compatible firmware from scratch.

[!IMPORTANT] Before reading further, review the Board Reference Matrix to understand the hardware constraints of your specific controller. Every piece of advice in this guide assumes you know your board’s limitations.


What Is the CeresFlows Protocol?

CeresFlows is an automation backend that manages sensors, relays, and actuators. It communicates with physical hardware controllers (microcontrollers) over a network or serial connection.

The communication model is simple:

CeresFlows Backend
       │
       │  Send: {"cmd": "ANALOG", "id": 1, "args": ["A0"]}
       ▼
  Your Controller (MCU)
       │
       │  Reply: {"ok": 1, "value": 487, "id": 1}
       ▼
CeresFlows Backend

The backend sends a command (a JSON object or a pipe-delimited string). The controller executes the command and sends back a response. That’s the entire protocol.


Controller Tiers

Not all controllers are equal. CeresFlows organizes them into two tiers:

🥇 Tier 1 — Main Controllers

Full-featured controllers that support all commands and all transport options (UDP, MQTT, Serial).

BoardChipNotes
Arduino UNO R4 WiFiRenesas RA4M1Reference implementation — all firmware examples originate here
ESP32 WROOM-32Espressif ESP32Recommended for production — dual-core, 320 KB RAM, dual hardware UART

A Main Controller handles the full range of sensor and actuator types: analog, digital, I2C, SPI, UART, Modbus, DHT, OneWire, ultrasonic, load cells, flow meters, and servos.

🥈 Tier 2 — Satellite Controllers

Controllers with limited hardware that support a subset of commands. Used for cost-sensitive or space-constrained installations.

BoardChipLimitation
ESP8266 NodeMCUEspressif ESP82661 analog input (max 1V), 1 hardware UART, less RAM
Arduino Nano (Classic)ATmega328PNo WiFi, 2 KB RAM, 32 KB Flash — Serial transport only

A Satellite Controller is a valid design choice. Dedicating a cheap ESP8266 to a single humidity sensor, or an Arduino Nano to a relay board via Serial, is a common and reliable pattern.

[!NOTE] The CeresFlows backend knows which commands each controller supports via the capabilities[] array reported in the INFO and HYDROPONICS_DISCOVERY responses. The UI automatically filters incompatible sensor types for each controller.


How the Backend Discovers Controllers

When a new controller comes online, CeresFlows discovers it in one of two ways:

1. UDP Broadcast Discovery (WiFi boards only)

The controller listens for a HYDROPONICS_DISCOVERY command sent as a UDP broadcast on port 8888. When received, it replies with its IP address, MAC address, firmware version, and capabilities list. The backend registers it automatically.

Backend → UDP Broadcast → {"cmd": "HYDROPONICS_DISCOVERY"}
Controller →             → {"type": "ANNOUNCE", "mac": "...", "ip": "...", "model": "...", "capabilities": [...]}

2. Manual Registration (All boards)

The controller can also be registered manually in the CeresFlows UI by entering its IP address (for WiFi boards) or selecting the serial port (for Serial-only boards). The backend then sends a PING to verify connectivity and an INFO command to read its capabilities.


Transport Options

Each transport option has different trade-offs:

TransportHow it worksBest for
UDPConnectionless, fast, low overhead. Commands and responses are individual UDP packets.Local network installations where low latency matters.
MQTTPublish/subscribe via a broker. More reliable delivery, supports remote access.Installations with unreliable WiFi, or where controllers must be monitored remotely.
SerialCommands arrive as newline-terminated strings on the USB serial port.Arduino Nano and other boards without WiFi. Also useful for debugging any board.

[!NOTE] All three transports are simultaneously active on WiFi boards. A controller connected via UDP can still receive commands over Serial for debugging. The Arduino Nano supports Serial only.

Every transport uses identical command and response formats — the firmware does not need to know which transport delivered the command.


Command Formats

CeresFlows supports two command formats. Any compatible firmware must support both.

JSON Protocol (Primary)

{"cmd": "ANALOG", "id": 42, "args": ["A0"]}
  • cmd — the command name (required)
  • id — a request ID echoed back in the response (optional, used for request correlation)
  • args — a JSON array of positional arguments
  • Named parameters for complex commands (MODBUS_RTU, I2C_TRANSFER, etc.) are passed as additional top-level fields

Pipe Protocol (Optimized Core)

ANALOG|A0
DIGITAL_WRITE|D5|1
  • Command name, followed by |, followed by arguments separated by |
  • Used for all simple commands — optimized for speed and minimal RAM usage

[!NOTE] JSON is the external interface — what you write in your commands and what the backend sends. Internally, the firmware converts all simple JSON args (ANALOG, DIGITAL_WRITE, RELAY_SET, etc.) into the Pipe format before routing to the handler. This keeps individual command handlers fast, simple, and MCU-agnostic. Both formats produce identical responses.


Response Format

Every response is a JSON object. There are only two top-level variants:

Success:

{"ok": 1, "value": 487, "id": 42}

Error:

{"ok": 0, "error": "ERR_INVALID_PIN", "id": 42}

The id field is always echoed back if it was present in the request. This allows the backend to correlate asynchronous responses.


Follow this reading order to build a complete understanding before writing any firmware:

StepDocumentWhat you learn
1Board Reference MatrixYour board’s exact capabilities and constraints
2Transport LayerHow to receive commands via UDP, MQTT, and Serial
3Command FormatFull JSON and Pipe protocol specification
4Response FormatHow to structure every response your firmware sends
5System CommandsPING, INFO, RESET, DISCOVERY — required by every firmware
6GPIO CommandsDigital and analog read/write
7Sensor CommandsDHT, OneWire, Ultrasonic, HX711, Pulse Counter
8Actuator CommandsPWM, Servo + TTL safety
9Bus CommandsI2C, UART, SPI, Modbus — the most complex commands
10TTL WatchdogSafety auto-shutoff mechanism
11CapabilitiesHow to declare what your firmware supports
12Error CodesComplete error code reference
13EEPROM PersistenceHow UART/Modbus config survives reboots
14Porting GuideStep-by-step checklist for a new MCU

Code Example Status

Throughout this documentation, every code example is labeled with its specific board and chip:

  • ✅ Tested — Verified on real hardware. Can be used directly.
  • ⚠️ Theoretical — Based on official chip documentation and specifications, but not yet verified on physical hardware. Use with care.
  • 🚧 In Progress — Under active development or testing.

The Arduino UNO R4 WiFi (Renesas RA4M1) firmware is the reference implementation — all its examples are ✅ Tested. Other boards are ⚠️ Theoretical unless explicitly stated otherwise.