Raspberry Pi Rack Temperature and Service Alert Monitor
Build a Raspberry Pi monitor with a supported digital temperature sensor, explicit wiring/calibration checks, durable readings, and a controlled service-alert test.
Expected Outcome
The Pi records calibrated temperature readings with timestamps, exposes a simple local status endpoint or log, detects a stopped test service, and delivers a verified alert without claiming to measure electrical power state unless an appropriate sensor is installed.
Assumptions
Raspberry Pi with current supported OS
Supported digital temperature sensor such as DS18B20 and correct resistor/wiring for the chosen interface
Basic low-voltage GPIO safety; never connect mains voltage to Pi GPIO
One disposable systemd service or remote health endpoint for alert testing
A defined local log/database location and notification destination
Bill of Materials
Raspberry Pi OS (Raspbian) installed on the MicroSD card
Python 3
Flask for web server
SQLite for data storage
DHT library for temperature sensor
GPIO library for relay control
Build Steps
- Wire and verify the sensor before writing the monitor
Use the sensor datasheet and Pi pinout to wire power, ground, and data correctly. Enable the supported kernel interface, confirm the device appears, and read raw temperature repeatedly before building persistence or alerts.
- Calibrate against a reference
Place the sensor beside a trusted thermometer for a stable period, record both values, and document acceptable offset/tolerance. Do not treat one plausible number as calibration.
- Implement a small collection service
Create a script that reads the sensor, timestamps the value, handles missing/invalid reads explicitly, and appends structured records to SQLite or a line-oriented file. Use the standard-library SQLite module rather than attempting to install sqlite3 as a pip dependency.
- Add service/endpoint state as a separate signal
Check one explicitly configured service or HTTP endpoint and record its status independently from temperature. Name the signal accurately; this is service availability, not electrical power measurement.
- Add threshold and failure alerting
Configure a temperature threshold/hysteresis and a service-failure condition. Send an alert through the chosen destination with sensor value/service state and timestamp. Avoid alerting on one invalid sensor read without a bounded retry policy.
- Exercise controlled failures
Warm the sensor safely or temporarily lower the test threshold to prove the temperature alert, and stop the disposable service to prove the availability alert. Restore both and confirm recovery state.
Validation
Sensor identity and raw readings are stable across multiple samples
Measured temperature is compared with a reference and tolerance is documented
Structured readings persist with timestamps and invalid reads are distinguishable from real values
A controlled threshold condition produces an alert
Stopping and restarting the test service produces failure and recovery evidence
No GPIO connection is used to measure mains power directly
Troubleshooting
Sensor absent: recheck interface enablement, wiring, pull-up requirement, and kernel device path
Implausible readings: compare raw values and reference thermometer before changing thresholds
Alert failure: test notification transport separately from sensor/service logic
Cleanup or Rollback
Stop/disable the lab collection service if no longer needed
Remove temporary threshold overrides and test notification credentials
Power down before disconnecting GPIO hardware
Next Improvements
Consider integrating email or SMS alerts for critical service issues.
Expand the project by adding additional sensors or monitoring capabilities.
