Skip to content

Commit

Permalink
Completed the Installation paragraph
Browse files Browse the repository at this point in the history
Added an example graph
  • Loading branch information
KirkBuah committed Aug 9, 2021
1 parent cb4352d commit c7c9611
Showing 1 changed file with 58 additions and 18 deletions.
76 changes: 58 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@

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.

The [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot) library was used to make the telegram bot.
![graph example](https://i.imgur.com/YO6baGM.jpeg)


## Structure

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.


## Installation

The following installation guide is divided in 3 phases.
### Dependencies

- [Adafruit_DHT](https://github.com/adafruit/Adafruit_Python_DHT)
- [matplotlib](https://matplotlib.org/stable/users/installing.html)
- [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot)

#### Raspberry Pi setup

Expand All @@ -24,37 +40,61 @@ Once your sensor is connected to your Raspberry Pi, go ahead and proceed to [ins
#### raspy-temperature-bot installation

To install raspy-temperature-bot:

1. Ssh into your Raspberry Pi
```bash
ssh pi@raspberrypi.local
```

2. Clone the repository
```bash
git clone https://github.com/Kirgnition/raspy-temperature-bot.git
```
3. Paste your [bot token](https://core.telegram.org/bots#6-botfather) in the `TOKEN.py` file
4.

#### Telegram bot setup


## Structure

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.

`bot.py` will call both the `Graph` and `TemperatureSensor` classes.
3. Paste your [bot token](https://core.telegram.org/bots#6-botfather) in the `TOKEN.py` file.

4. Create a service for the temperature sensor:
1. Create a file called `temperature_sensor.service`:
```bash
sudo nano /etc/systemd/system/temperature_sensor.service
```
2. 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=`.

3. Enable the service by issuing on the terminal:
```bash
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.

5. 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.

## Usage

Once the bot is installed and running, send the `/start` command on telegram to receive a set of instructions.
Once the bot is installed and running, send the `/start` command on telegram to receive the list of available commands.

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License
[MIT](https://choosealicense.com/licenses/mit/)

0 comments on commit c7c9611

Please sign in to comment.