🕑 Changelog 🎁 Acknowledgements 🇵🇱 Polish version of README
- DS18B20 (temperature)
- DHT11 (humidity)
- Measure current temperature and humidity
- Save temperature and humidity to database
- Simple website with current readings
-
Connect the DS18B20 and DHT11 sensors to the Raspberry Pi.
-
Clone repository
git clone https://github.com/bartekl1/rpi-thermometer cd rpi-thermometer
-
Create database and import structure from
thermometer.sql
file. -
Create configuration file named
configs.json
with the following content.{ "host": "0.0.0.0", "mysql_user": "<mysql_user>", "mysql_password": "<mysql_password>", "mysql_database": "<mysql_database>" }
Replace
<mysql_user>
,<mysql_password>
and<mysql_database>
with correct credentials. -
Install PIP dependencies.
pip install -r requirements.txt
-
Create
/etc/systemd/system/thermometer.service
file with the following content.[Unit] Description=Thermometer After=network.target [Service] WorkingDirectory=<PATH> ExecStart=/usr/bin/python3 <PATH>/app.py Restart=always User=<USERNAME> [Install] WantedBy=multi-user.target
Replace
<PATH>
with path to the cloned repository and<USERNAME>
with your system username. -
Start and enable created service.
sudo systemctl start thermometer sudo systemctl enable thermometer
-
Add following line to crontab (edit using
crontab -e
).*/10 * * * * cd "<PATH>" && python3 save_to_database.py
Replace
<PATH>
with path to the cloned repository. You can edit cron expression to change frequency.