Temperature and humidity sensor (SHT35) - Bedroom

This project involves a real-time temperature and humidity monitoring system implemented in a bedroom using the SHT35 sensor and a Raspberry Pi. The system reads sensor data every 5 minutes, stores it in a SQLite database, and visualizes the information on a web interface.

The hardware setup consists of:

  • SHT35 temperature and humidity sensor connected via I2C to a Raspberry Pi.
  • Raspberry Pi running a Python backend with Flask for data acquisition and API endpoints.
  • Optional display of historical data through charts in a responsive web page.
SHT35 - Temperature & Humidity Sensor
Feature Specification
Manufacturer Sensirion
Model SHT35
Sensor type Digital Temperature and Humidity Sensor
Interface I²C
Supply voltage 2.4 V – 5.5 V
Temperature range -40 °C to +125 °C
Temperature accuracy ±0.1 °C (typical)
Humidity range 0 – 100 % RH
Humidity accuracy ±1.5 % RH (typical)
Temperature resolution Up to 0.01 °C
Humidity resolution Up to 0.01 % RH
Response time ~8 seconds
Power consumption Very low
Calibration Factory calibrated
Typical applications Environmental monitoring, IoT, home automation

Fig.1 - Sensor characteristics SHT35.

Here is the schematic of the circuit. Connecting the SHT35 Sensor with the Rpi 4 using I2C.

Fig.2 - Schematic of the circuit.

The software implementation includes:

  • Python script that reads the sensor and inserts data into a SQLite database.
  • Flask REST API providing endpoints for the latest measurement, daily data, averages, and database download.
  • Front-end built in HTML/CSS/JavaScript using Chart.js to render interactive graphs of temperature and humidity.

The data visualization is designed for clarity and ease of use:

  • Left Y-axis shows temperature (°C) and right Y-axis shows humidity (%), allowing both datasets to be overlaid.
  • Interactive points for each measurement and smooth lines to indicate trends.
  • Automatic updates every 10 seconds for the latest measurement and 60 seconds for the graph.

The project code is modular and can be extended to multiple sensors.

# Python Flask Backend Example from flask import Flask, jsonify import sqlite3 from datetime import datetime app = Flask(__name__) DB_PATH = 'temperature_readings.db' @app.route('/api/latest') def latest(): conn = sqlite3.connect(DB_PATH) c = conn.cursor() c.execute("SELECT timestamp, temp, hum FROM readings ORDER BY timestamp DESC LIMIT 1") row = c.fetchone() conn.close() if row: return jsonify(timestamp=row[0], temp=row[1], hum=row[2]) else: return jsonify(timestamp=None, temp=None, hum=None) @app.route('/api/data') def data(): # Example endpoint to fetch data of a specific date return jsonify(values=[]) if __name__ == '__main__': app.run(host='0.0.0.0', port=5000)

Fig.3 - Full Python code.

This way, I can monitor the temperature and humidity in my room throughout the day (or even the year). And everything is saved in a database for future reference.

Here's a general overview of how I have the sensor and the Raspberry Pi set up.

Fig.4 - General overview of the sensor and micro.

It is now possible to view temperature and humidity in real time. Measurements are taken every 5 minutes, the values ​​are stored in a database, and a graph is generated relating temperature and humidity as a function of time, you can see here: https://joelbonifacio.dynip.sapo.pt/electro6.html

Leave A Comment