This is a telegram bot hosted by a Raspberry Pi equipped with a temperature and humidity sensor. The bot is capable of sending plots and readings.
Note: This project is currently not maintained.
This is a telegram bot hosted by a Raspberry Pi equipped with a temperature and humidity sensor. The bot is capable of sending plots and readings.
This project is composed of 3 main files:
bot.py
is used to host the telegram bot.graph.py
contains the Graph
class, used to make graphs.sensor.py
contains the TemperatureSensor
class, used to write and read from the sqlite3 database, as well as the
function that reads the temperature and humidity values from the sensor.bot.py
will call both the Graph
and TemperatureSensor
classes.
To make this project i used a Raspberry Pi Zero W with an AM2302 temperature and humidity sensor.
The humidity sensor has 3 pins:
Once your sensor is connected to your Raspberry Pi, go ahead and proceed to install a clean version of Raspberry Pi OS Lite.
To install raspy-temperature-bot:
ssh [email protected]
git clone https://github.com/Kirgnition/raspy-temperature-bot.git
cd ./raspy-temperature-bot
pip3 install -r ./requirements.txt
Paste your bot token in the TOKEN.py
file.
Create a service for the temperature sensor:
Create a file called temperature_sensor.service
:
sudo nano /etc/systemd/system/temperature_sensor.service
Paste the following:
[Unit]
Description=ROT13 demo service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=username
ExecStart=python3 /path/to/sensor.py
[Install]
WantedBy=multi-user.target
Set your username after User=
and the path to sensor.py
after ExecStart=
.
Enable the service by issuing on the terminal:
systemctl start temperature_sensor.service
systemctl enable temperature_sensor.service
From the moment you start the service a reading will be taken by the sensor every 5 minutes and saved in a sqlite3 database.
Create a service for the telegram bot in an analogous way.
Your bot should be now active, in case of restart both the bot and the sensor will start automatically.
Once the bot is installed and running, send the /start
command on telegram to receive the list of available commands.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.