Real-time Temperature & Humidity Dashboard
Powered by Raspberry Pi 4 • DHT11 Sensor • Flask
TemperStat is an IoT project that reads temperature (°C) and humidity (%) from a DHT11 sensor connected to a Raspberry Pi 4 via GPIO pin 17, and serves a live dashboard using Flask. Readings auto-refresh every 5 seconds and are logged to a CSV file that can be emailed to any address directly from the web UI.
| Feature | Description |
|---|---|
| 🌡️ Live Temperature | Current reading in °C with session min / max |
| 💧 Live Humidity | Current reading in % with session min / max |
| 📊 Historical Table | Last 11 readings displayed in a clean table |
| 📧 Email Export | Enter an email address → receive readings.csv as an attachment |
| 🔄 Auto-Refresh | Dashboard refreshes every 5 seconds for near-real-time updates |
| 📝 CSV Logging | Every reading is appended to readings.csv with a timestamp |
| Layer | Technology |
|---|---|
| Hardware | Raspberry Pi 4, DHT11 sensor |
| Backend | Python 3, Flask |
| Sensor Library | Adafruit_DHT |
| Frontend | Jinja2 templates, Bulma CSS, Font Awesome icons |
smtplib via Gmail SMTP (TLS) |
|
| Data Store | In-memory lists (session) + readings.csv (persistent) |
TemperStat/
├── app.py # Flask application — routes, sensor reading, email
├── readings.csv # Append-only log of all sensor readings
├── templates/
│ ├── index.html # Main dashboard — live stats, table, email form
│ └── mail.html # Confirmation page after successful email send
├── LICENSE
└── README.md
Raspberry Pi 4 GPIO
─────────────────────
Pin 1 (3.3 V) ──→ DHT11 VCC
Pin 7 (GPIO 17) ──→ DHT11 DATA
Pin 9 (GND) ──→ DHT11 GND
A 10 kΩ pull-up resistor between VCC and DATA is recommended for reliable reads.
- Raspberry Pi 4 running Raspbian / Raspberry Pi OS
- Python 3 installed
- DHT11 sensor wired to GPIO 17
# Clone the repository
git clone https://github.com/SahilGothoskar/TemperStat.git
cd TemperStat
# Install dependencies
pip install flask Adafruit_DHT
# Run the application
python app.pyThe dashboard will be available at http://localhost:5000.
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Reads the sensor, logs the data, and renders the dashboard |
POST |
/mail |
Sends readings.csv to the email address from the form |
The app sends mail through Gmail SMTP. Update the following constants in app.py to use your own credentials:
MY_EMAIL = "your-email@gmail.com"
MY_PASSWORD = "your-app-password"Tip: Use a Gmail App Password instead of your account password.
Readings are appended to readings.csv with the following columns:
| Column | Example |
|---|---|
| Time | 14:32:07 |
| Temperature | 28 |
| Humidity | 65 |
- The dashboard auto-refreshes every 5 seconds (
<meta http-equiv="refresh" content="5">), so every page load triggers a new sensor read. - In-memory lists (
data_temp,data_hum,data_time) reset when the Flask process restarts. The CSV file persists across restarts. Adafruit_DHT.read_retry()retries up to 15 times internally to handle the sensor's occasional missed reads.
| Name | GitHub | |
|---|---|---|
| 🧑💻 | Sahil Gothoskar | @SahilGothoskar |
| 🧑💻 | Aditya Borgaonkar | @adityaborgaonkar |
Made with ❤️ on a Raspberry Pi
