Skip to main content

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.

AgroPulse accepts sensor readings over plain HTTP, making it straightforward to integrate any device capable of making REST calls — from an ESP32 running Arduino firmware to a Raspberry Pi script. You can start streaming data immediately without pre-registering sensors, or you can register sensors explicitly and reference them by ID for more precise control.

Supported sensor types

The following sensorType values are recognised by AgroPulse:
ValueMeasurementUnit
TEMPERATUREGeneral temperature°C
TEMPERATURE_INTERNALGreenhouse interior temperature°C
TEMPERATURE_EXTERNALAmbient exterior temperature°C
HUMIDITYRelative humidity%
SOIL_MOISTURESoil moisture level%
LIGHTLuminositylux
CO2Carbon dioxide concentrationppm
PHSoil pHpH
WIND_SPEEDWind speed (outdoor sensors)m/s

Registration strategies

The simplest approach: post a reading with greenhouseId and sensorType but omit sensorId (or set it to 0). AgroPulse will look up or create the corresponding sensor automatically.
curl -s -X POST http://localhost:8080/api/readings \
  -H "Content-Type: application/json" \
  -d '{
    "greenhouseId": 1,
    "sensorType": "SOIL_MOISTURE",
    "value": 42.5,
    "source": "esp32-abc123"
  }'
AgroPulse performs the following lookup on every auto-registered reading:
  1. If source is present, search for an existing sensor with the same greenhouseId, deviceSource, and type.
  2. If no match is found, create a new sensor named SOIL_MOISTURE (auto) and link it to the greenhouse.
  3. Store the reading against the resolved sensor ID.
Subsequent readings with the same source and sensorType reuse the existing sensor record — no duplicate sensors are created.
The source field maps to the deviceSource column on the Sensor entity. Set it to a stable device identifier such as the ESP32 chip ID or MAC address. This value is used for sensor deduplication: two readings with the same source, sensorType, and greenhouseId always resolve to the same sensor row.

ESP32 example — multiple readings in one loop

The following example shows a realistic Arduino/ESP32 sketch posting temperature and soil-moisture readings every 30 seconds using auto-registration:
# Simulated with curl; replace with equivalent WiFiClient / HTTPClient code on-device

DEVICE_ID="esp32-abc123"
GREENHOUSE_ID=1
BASE="http://localhost:8080/api/readings"

# Temperature reading
curl -s -X POST "$BASE" \
  -H "Content-Type: application/json" \
  -d "{\"greenhouseId\":$GREENHOUSE_ID,\"sensorType\":\"TEMPERATURE_INTERNAL\",\"value\":24.3,\"source\":\"$DEVICE_ID\"}"

# Humidity reading
curl -s -X POST "$BASE" \
  -H "Content-Type: application/json" \
  -d "{\"greenhouseId\":$GREENHOUSE_ID,\"sensorType\":\"HUMIDITY\",\"value\":68.1,\"source\":\"$DEVICE_ID\"}"

# Soil moisture reading
curl -s -X POST "$BASE" \
  -H "Content-Type: application/json" \
  -d "{\"greenhouseId\":$GREENHOUSE_ID,\"sensorType\":\"SOIL_MOISTURE\",\"value\":39.7,\"source\":\"$DEVICE_ID\"}"

# CO2 reading
curl -s -X POST "$BASE" \
  -H "Content-Type: application/json" \
  -d "{\"greenhouseId\":$GREENHOUSE_ID,\"sensorType\":\"CO2\",\"value\":812.0,\"source\":\"$DEVICE_ID\"}"

Querying readings back

# Last 100 readings for a greenhouse
curl "http://localhost:8080/api/readings?greenhouseId=1&limit=100"

# Readings for a specific sensor
curl "http://localhost:8080/api/readings?sensor=7&limit=50"
Results are always returned in descending timestamp order.

Build docs developers (and LLMs) love