Overview
The Temperature Plants endpoint allows you to submit temperature readings from sensors monitoring plant environments. This endpoint tracks ambient temperature in plant growing areas.Endpoint
Model Structure
TheTemperaturaPlantas model extends the base Sensor model:
models.py:13-17
ViewSet Implementation
views.py:124-130
Authentication
Request Parameters
Sensor name identifierExample:
"Temperatura"Type of sensor locationExample:
"Plantas"Sensor group classificationExample:
"Grupo P"Temperature reading from the sensorExample:
22.8Unit of measurement for temperatureDefault:
"graus"Example: "graus"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
Temperature value submitted
Unit of measurement for the temperature
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 usesTemperaturaPlantasSerializer with depth=1 to include related object details:
serializers.py:41-50
Use Cases
- Monitor plant environment temperature in real-time
- Track temperature fluctuations in growing areas
- Trigger alerts when temperature is outside optimal range
- Historical temperature data analysis for plant health
- IoT device integration via MQTT
- Greenhouse climate control
Best Practices
- Regular Readings: Submit temperature readings at consistent intervals (e.g., every 5-10 minutes)
- Valid Ranges: Ensure temperature values are within reasonable ranges for plant environments (typically 15-35°C)
- Error Handling: Implement retry logic for failed submissions
- Data Validation: Validate sensor readings before submission to avoid spurious data
Related Endpoints
- Temperature Aquarium API - For aquarium water temperature
- Humidity API - For monitoring humidity in plant environments
- Light Sensor API - For monitoring light levels
