A real-time environmental monitoring system using Raspberry Pi, DHT11 sensor, and I2C LCD display.
- Temperature and humidity monitoring using DHT11 sensor
- Real-time display on 16x2 I2C LCD screen
- Data logging with timestamp
- JSON file storage organized by date
- Automatic data collection every 5 minutes
- Raspberry Pi (any model)
- DHT11 Temperature and Humidity Sensor
- 16x2 LCD Display with I2C backpack (PCF8574)
- Jumper wires (female-to-female)
- Breadboard (optional)
- VCC (Power) → 3.3V (Pin 1)
- GND (Ground) → Ground (Pin 6)
- DATA → GPIO4 (Pin 7)
- VCC → 5V (Pin 2)
- GND → Ground (Pin 6)
- SDA → GPIO2/SDA (Pin 3)
- SCL → GPIO3/SCL (Pin 5)
- Enable I2C interface on Raspberry Pi:
sudo raspi-config
# Navigate to Interface Options → I2C → Enable
- Install required system packages:
sudo apt-get update
sudo apt-get install python3-pip git python3-smbus i2c-tools
- Verify I2C LCD connection:
sudo i2cdetect -y 1
You should see the LCD address (usually 0x27) in the output.
- Clone this repository:
git clone https://github.com/yourusername/room-weather-station.git
cd room-weather-station
- Install Python dependencies:
pip3 install -r requirements.txt
- Run the weather station:
python3 weather_station.py
- Copy the service file to systemd:
sudo cp weather-station.service /etc/systemd/system/
- Enable and start the service:
sudo systemctl enable weather-station
sudo systemctl start weather-station
Data is stored in JSON format in the data
directory. Files are organized by date (e.g., weather_data_2024-01-20.json
).
Each reading contains:
- Timestamp
- Temperature (°C)
- Humidity (%)
The 16x2 LCD display shows:
- Line 1: Current temperature in Celsius
- Line 2: Current humidity percentage
The display updates every 5 minutes along with data logging.
Check service status:
sudo systemctl status weather-station
View logs:
journalctl -u weather-station
-
If the LCD doesn't display:
- Check I2C address using
sudo i2cdetect -y 1
- Verify wiring connections
- Ensure I2C is enabled in raspi-config
- Check I2C address using
-
If sensor readings fail:
- Check DHT11 wiring
- Verify GPIO pin number in code matches your connection
- Ensure proper power supply to Raspberry Pi