Overview
The TDS Sensor endpoint allows you to submit Total Dissolved Solids (TDS) readings from sensors monitoring aquarium water quality. TDS measurements indicate the concentration of dissolved substances in water, which is critical for maintaining healthy aquatic environments.Endpoint
Model Structure
TheTds model extends the base Sensor model:
models.py:45-50
ViewSet Implementation
views.py:142-148
Authentication
Request Parameters
Sensor name identifierExample:
"TDS"Type of sensor locationExample:
"Acuario"Sensor group classificationExample:
"Grupo A"Current TDS reading from the sensor (parts per million)Example:
320.5Average or target TDS levelDefault:
30Example: 100Unit of measurement for TDSDefault:
"ppm"Example: "ppm"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
TDS value submitted (parts per million)
Average or target TDS level
Unit of measurement for TDS (typically ppm)
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 usesTdsSerializer with depth=1 to include related object details:
serializers.py:65-74
Use Cases
- Monitor water quality in aquariums in real-time
- Track dissolved solids concentration over time
- Trigger water changes when TDS levels exceed safe thresholds
- Ensure optimal water quality for aquatic life
- Historical water quality data analysis
- IoT device integration via MQTT
- Automated filtration system control
Understanding TDS Values
TDS measures the concentration of dissolved inorganic and organic substances in water:Acceptable TDS Ranges
- Freshwater Aquariums: 50-300 ppm
- Planted Tanks: 150-250 ppm
- Saltwater Aquariums: 30,000-40,000 ppm (measured differently)
- Drinking Water: < 500 ppm (EPA standard)
What TDS Measures
- Dissolved minerals (calcium, magnesium, sodium)
- Salts
- Metals
- Organic matter
- Other dissolved substances
TDS does not measure contaminants, bacteria, or other harmful substances. It’s an indicator of overall dissolved content but should be used alongside other water quality tests.
Best Practices
- Regular Monitoring: Submit TDS readings every 10-30 minutes for real-time tracking
- Calibration: Calibrate TDS sensors regularly with standard solutions
- Temperature Compensation: Many TDS sensors are temperature-dependent; ensure proper compensation
- Baseline Tracking: Use
media_tdsto track target TDS levels for your specific aquarium - Water Changes: Plan water changes when TDS exceeds safe thresholds
- Gradual Changes: Avoid sudden TDS changes that can stress aquatic life
Safety Considerations
Troubleshooting High TDS
If TDS levels are too high:- Perform partial water changes with purified water
- Check for overfeeding (uneaten food increases TDS)
- Inspect filtration system functionality
- Test source water TDS before adding to aquarium
- Consider using reverse osmosis (RO) water for dilution
Related Endpoints
- Temperature Aquarium API - For aquarium water temperature
- Water Level API - For monitoring water levels
- Light Sensor API - For monitoring light levels
