Overview
The Light Sensor (LDR) endpoint allows you to submit light intensity readings from Light Dependent Resistor (LDR) sensors monitoring plant environments. This endpoint tracks luminosity levels to ensure optimal lighting conditions.Endpoint
Model Structure
TheLdr model extends the base Sensor model:
models.py:38-43
ViewSet Implementation
views.py:133-139
Authentication
Request Parameters
Sensor name identifierExample:
"LDR"Type of sensor locationExample:
"Plantas"Sensor group classificationExample:
"Grupo P"Current light intensity reading from the sensorExample:
450.5Average or target light intensity levelDefault:
30Example: 30Unit of measurement for light intensityDefault:
"lumen"Example: "lumen"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 light intensity value submitted
Average or target light intensity level
Unit of measurement for light intensity
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 usesLdrSerializer with depth=1 to include related object details:
serializers.py:53-62
Use Cases
- Monitor light intensity in plant growing environments
- Track daily light cycles for optimal plant growth
- Automate grow lights based on natural light levels
- Ensure plants receive adequate light for photosynthesis
- Historical light data analysis
- IoT device integration via MQTT
- Greenhouse light management
Light Requirements by Plant Type
Different plants require different light levels:- Low Light Plants: 50-250 lumens (Snake plants, Pothos)
- Medium Light Plants: 250-1000 lumens (Ferns, Philodendrons)
- High Light Plants: 1000+ lumens (Succulents, Cacti, Tomatoes)
- Seedlings: 2000-3000 lumens for optimal growth
Best Practices
- Regular Readings: Submit light readings at consistent intervals (e.g., every 10-15 minutes)
- Daily Cycles: Monitor throughout the day to track natural light variations
- Sensor Placement: Position LDR sensors at plant canopy level
- Calibration: Regularly calibrate sensors for accuracy
- Baseline Tracking: Use
media_luminosidadeto track target light levels - Seasonal Adjustments: Account for seasonal variations in natural light
LDR Sensor Notes
LDR (Light Dependent Resistor) sensors provide analog readings that vary with light intensity. Lower resistance indicates higher light levels. The sensor readings should be converted to lumens or lux for meaningful measurements.
Related Endpoints
- Temperature Plants API - For monitoring temperature in plant environments
- Humidity API - For monitoring humidity levels
- Water Level API - For monitoring water levels
