The Sensors API is the central registry for every physical sensor connected to an AgroPulse greenhouse. Each record describes a single measurement point — its type, hardware address, communication protocol, and which greenhouse it belongs to. Clients such as ESP32 edge nodes and the dashboard frontend use this API to discover active sensors before submitting readings.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.
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/sensors | List all sensors, optionally filtered by greenhouse |
POST | /api/sensors | Create a sensor (or update an existing one via upsert) |
GET | /api/sensors/{id} | Retrieve a single sensor by ID |
PUT | /api/sensors/{id} | Update a sensor by ID |
DELETE | /api/sensors/{id} | Remove a sensor by ID |
GET /api/sensors
Returns all registered sensors. PassgreenhouseId to scope the result to a single greenhouse.
Query parameters
When provided, only sensors belonging to this greenhouse are returned.
Response
curl example
POST /api/sensors
Creates a new sensor. If the combination ofdeviceSource, type, and gpioPin matches an existing record, the API performs an update instead of inserting a duplicate. This upsert behavior is designed for ESP32 nodes that re-register their sensors on boot.
Upsert matching requires all three fields —
deviceSource, type, and gpioPin — to be present and non-blank. When any of the three is missing, a new record is always created.Body parameters
Human-readable label for the sensor, e.g.
"Roof DHT22".Measurement category. Must be one of the
SensorType enum values listed below.ID of the greenhouse this sensor belongs to.
Physical location description, e.g.
"North wing, ceiling".Most recent measurement value. Updated by the readings pipeline automatically.
Whether the sensor should be included in monitoring and anomaly detection.
GPIO pin number on the microcontroller board. Required for upsert matching.
Communication protocol. Common values:
DHT22, DHT11, ADC, I2C, DIGITAL.Identifier of the ESP32 or other device that registered this sensor (e.g.
"esp32-node-01"). Required for upsert matching.SensorType values
All supported sensor types
All supported sensor types
| Value | Unit | Description |
|---|---|---|
TEMPERATURE | °C | General-purpose temperature |
HUMIDITY | % | Relative air humidity |
SOIL_MOISTURE | % | Soil moisture level |
LIGHT | lux | Ambient light intensity |
CO2 | ppm | Carbon dioxide concentration |
PH | pH | Soil or solution pH |
WIND_SPEED | m/s | Wind speed (outdoor sensors) |
TEMPERATURE_INTERNAL | °C | Temperature inside the greenhouse structure |
TEMPERATURE_EXTERNAL | °C | Temperature outside the greenhouse structure |
curl example
GET /api/sensors/
Returns a single sensor record.Path parameters
The sensor ID.
Response
Auto-generated sensor identifier.
Human-readable label.
SensorType enum value.Physical location description.
ID of the owning greenhouse.
Most recent measurement value stored for this sensor.
Whether the sensor is currently monitored.
GPIO pin number on the connected microcontroller.
Communication protocol (e.g.
DHT22, I2C).Identifier of the originating ESP32 device.
curl example
PUT /api/sensors/
Updates an existing sensor. Only the fields included in the request body are changed; omitted fields retain their current values.Path parameters
The sensor ID to update.
Body parameters
All body fields are optional. Provide only the fields you want to change.Updated sensor label.
Updated
SensorType enum value.Updated physical location.
Reassign to a different greenhouse.
Override the last recorded value.
Enable or disable monitoring for this sensor.
Updated GPIO pin number.
Updated communication protocol.
Updated device source identifier.
curl example
DELETE /api/sensors/
Permanently removes a sensor record.Path parameters
The sensor ID to delete.