Overview
The Water Level endpoint allows you to submit water level readings from sensors monitoring aquarium water levels. This endpoint tracks water depth and helps maintain optimal water levels.Endpoint
Model Structure
TheNivelAgua model extends the base Sensor model:
models.py:31-36
ViewSet Implementation
views.py:115-121
Authentication
Request Parameters
Sensor name identifierExample:
"Nível de Água"Type of sensor locationExample:
"Acuario"Sensor group classificationExample:
"Grupo A"Current water level reading from the sensorExample:
45.5Minimum acceptable water level thresholdDefault:
200Example: 30Unit of measurement for water levelDefault:
"centímetros"Example: "centímetros"Response Fields
Auto-generated unique identifier for the record
Sensor name as provided in request
Sensor type as provided in request
Sensor group as provided in request
Current water level value submitted
Minimum water level threshold
Unit of measurement for the water level
Timestamp when the record was created (auto-generated)
Example Request
Example Response
Status Code:201 Created
Error Responses
Missing Authentication Token
Status Code:401 Unauthorized
Invalid Token
Status Code:401 Unauthorized
Missing Required Fields
Status Code:400 Bad Request
Invalid Data Type
Status Code:400 Bad Request
MQTT Integration Example
Example from the Raspberry Pi MQTT client:Serializer Details
The endpoint usesNivelAguaSerializer with depth=1 to include related object details:
serializers.py:29-38
Use Cases
- Monitor aquarium water level in real-time
- Track water evaporation rates over time
- Trigger alerts when water level drops below minimum threshold
- Automate water refill systems
- Prevent pump damage from low water levels
- Historical water level data analysis
- IoT device integration via MQTT
Water Level Monitoring Best Practices
- Set Appropriate Thresholds: Configure
nivel_minimobased on your aquarium requirements - Regular Readings: Submit readings at consistent intervals (e.g., every 10-15 minutes)
- Calibration: Regularly calibrate sensors for accuracy
- Alert Systems: Implement alerts when level drops below
nivel_minimo - Evaporation Compensation: Account for normal evaporation rates in your monitoring
Safety Considerations
Related Endpoints
- Temperature Aquarium API - For aquarium water temperature
- TDS Sensor API - For water quality monitoring
- Humidity API - For monitoring environmental humidity
