The Device API is the integration point for ESP32 microcontrollers and other edge hardware. Devices use these endpoints at boot time to register their sensors and actuators with the server and download the current configuration for their assigned greenhouse. The frontend uses the GPIO availability endpoint to populate pin-picker UI elements.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/diarpicu2022-commits/backend-AgroPulse/llms.txt
Use this file to discover all available pages before exploring further.
All device endpoints are served under
/api/device. They are designed for firmware-level HTTP calls from ESP32 nodes, though they work from any HTTP client.POST /api/device/register
Registers an ESP32 device and its connected hardware. The device reports itsdeviceId and greenhouseId, along with lists of sensors and actuators it has wired up. The server upserts each sensor and actuator record so boot-time registration is always safe to call repeatedly.
Request body
ID of the greenhouse this device belongs to. The request fails with
400 if this is missing or zero.Unique identifier for the ESP32 device, e.g.
"esp32-gh3-01". Defaults to "UNKNOWN" if omitted.List of sensor descriptor objects. Each entry follows the same shape as the
POST /api/sensors body (see Sensors API). Omit or pass [] if the device has no sensors.List of actuator descriptor objects. Each entry follows the same shape as the
POST /api/actuators body (see Actuators API). Omit or pass [] if the device has no actuators.| Status | Cause |
|---|---|
400 | greenhouseId is missing or zero. |
GET /api/device/config/
Downloads the full hardware configuration for a greenhouse. ESP32 devices call this at boot to learn which sensors and actuators they should be managing and what their current states are. Path parametersThe greenhouse whose configuration to retrieve.
GET /api/device/gpios/
Returns the GPIO pin availability for a greenhouse — which pins are already allocated to sensors or actuators, and which remain free for new hardware. This endpoint is used by the frontend’s GPIO pin-picker when adding new devices. Path parametersThe greenhouse whose GPIO allocation to query.
List of GPIO pin numbers already assigned to sensors or actuators in this greenhouse.
GPIO pins that are valid for sensor input and not yet assigned. Drawn from the ESP32 DevKit input-capable pins: 4, 5, 12–19, 23, 25–27, 32–36, 39.
GPIO pins that are valid for actuator output and not yet assigned. Drawn from the ESP32 DevKit output-capable pins: 4, 5, 12–19, 23, 25–27, 32–33.
GPIO pins 0, 1, 2, 3, 6–11, 21, and 22 are reserved for system use on ESP32 DevKit boards and are never returned as available.