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.

Overview

raspy-temperature-bot

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.

graph example

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

Dependencies

Raspberry Pi setup

To make this project i used a Raspberry Pi Zero W with an AM2302 temperature and humidity sensor.

The humidity sensor has 3 pins:

  • DATA, connected to the GPIO 4 port, it sends the readings to the Raspberry Pi.
  • GROUND, connected to one of the ground ports.
  • VCC, connected to one of the 5V ports.

gpio pinout

Once your sensor is connected to your Raspberry Pi, go ahead and proceed to install a clean version of Raspberry Pi OS Lite.

raspy-temperature-bot installation

To install raspy-temperature-bot:

  1. Ssh into your Raspberry Pi
  1. Clone the repository
git clone https://github.com/Kirgnition/raspy-temperature-bot.git
  1. cd into the repository and install the requirements.
cd ./raspy-temperature-bot
pip3 install -r ./requirements.txt
  1. Paste your bot token in the TOKEN.py file.

  2. Create a service for the temperature sensor:

    1. Create a file called temperature_sensor.service:

      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:

      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.

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

License

MIT

You might also like...
Bill is a bot capable to Chat with you, search everything on web to you, and send message to yours contacts for you.

Bill Bot The inteligent Bot Bill is a intelligent bot, it can chat, search and send messages to you. Chat with You Send messages on WhatsApp for you S

This is Pdisk Upload Bot made using Python with Pyrogram Framework. Its capable of uploading direct download link with thumbnail or without thumbnail & with Title Support.

Pdisk-Upload-Bot Introduction This Is PDisk Upload Bot Used To Upload Direct Link To Pdisk With Thumb Support Deploy Heroku Deploy Local Deploy pip in

Telegram bot to stream videos in telegram voicechat for both groups and channels. Supports live strams, YouTube videos and telegram media.

Telegram VCVideoPlayBot An Telegram Bot By @ZauteKm To Stream Videos in Telegram Voice Chat. NOTE: Make sure you have started a VoiceChat in your Grou

Telegram bot to stream videos in telegram voicechat for both groups and channels. Supports live strams, YouTube videos and telegram media.

Telegram bot to stream videos in telegram voicechat for both groups and channels. Supports live strams, YouTube videos and telegram media.

A Twitter bot written in Python using Tweepy and hosted on a server.
A Twitter bot written in Python using Tweepy and hosted on a server.

A Twitter bot written in Python using Tweepy. It can like and/or retweet tweets that contain single or multiple keywords and hashtags.

A Twitter bot developed in Python using the Tweepy library and hosted in AWS.

Twitter Cameroon: @atangana_aron A Twitter bot developed in Python using the Tweepy library and hosted in AWS. https://twitter.com/atangana_aron Cost

A self hosted slack bot to conduct standups & generate reports.
A self hosted slack bot to conduct standups & generate reports.

StandupMonkey A self hosted slack bot to conduct standups & generate reports. Report Bug · Request Feature Installation Install already hosted bot (Us

A self-hosted Discord music bot.
A self-hosted Discord music bot.

Cassette A self-hosted Discord music bot. Requirements py-cord pynacl pytube Setup Intended to be hosted on Heroku. Fork or clone this repo. Create a

Comments
  • 'generator' object is not subscriptable

    'generator' object is not subscriptable

    Hi, in the log-file I get some TypeErrors, for example:

    File "/home/wjmb/raspy-temperature-bot/graph.py", line 50, in make_graph
        datemin = dates[0]
    TypeError: 'generator' object is not subscriptable
    

    or:

    File "/home/wjmb/raspy-temperature-bot/bot.py", line 53, in last_readings
        timestr = data.dates[0].datetime.strftime('%Y/%m/%d at %H:%M')
    TypeError: 'generator' object is not subscriptable
    

    This is on a RPI4, Python version 3.9.2

    opened by wjmb 19
Releases(v0.1)
Owner
null
Cryptocurrency Trading Bot - A trading bot to automate cryptocurrency trading strategies using Python, equipped with a basic GUI

Cryptocurrency Trading Bot - A trading bot to automate cryptocurrency trading strategies using Python, equipped with a basic GUI. Used REST and WebSocket API to connect to two of the most popular crypto exchanges in the world.

Francis 8 Sep 15, 2022
A Python app which retrieves the rank and players' equipped skins during a match

VALORANT rank yoinker About The Project Usage Contributing Contact Acknowledgements Disclaimer About The Project Their Queue Current Skin Current Rank

Isaac Kenyon 270 Jan 4, 2023
Force-Subscribe-Bot - A Telegram Bot to force users to join a specific channel before sending messages in a group

Introduction A Telegram Bot to force users to join a specific channel before sen

LG Bot Updates 0 Jan 16, 2022
Telegram Bot Repo Capable of fetching the following Info via Anilist API inspired from AniFluid and Nepgear

Telegram Bot Repo Capable of fetching the following Info via Anilist API inspired from AniFluid and Nepgear Anime Airing Manga Character Scheduled Top

Rikka-Chan 2 Apr 1, 2022
Melissa Songs is a telegram bot to easily find songs sending music snippets and search tracks 💃🏽🎵

Find songs on Telegram, like on Shazam... ?? Open on telegram · Report Bug · Request Feature ⬇️ Installation To get a local copy installed and working

Joaquim Roque 21 Nov 10, 2022
Pogodasbot - Telegram bot sending channel weather info

Pogodasbot - Telegram bot sending channel weather info

Qayrat Sultan 1 Dec 15, 2022
Temperature Monitoring and Prediction Using a Modified Lambda Architecture

Temperature Monitoring and Prediction Using a Modified Lambda Architecture A more detailed write up can be seen in this paper. Original Lambda Archite

Parsa Yousefi 2 Jun 27, 2022
Using multiple API sources, create an app that allows users to filter through random locations based on their temperature range choices.

World_weather_analysis Overview Using multiple API sources, create an app that allows users to filter through random locations based on their temperat

Jason Boyer 2 Sep 16, 2022
null 1 Feb 18, 2022
ShotsGram - For sending captures from your monitor to a telegram chat (robot)

ShotsGram pt-BR Envios de capturas do seu monitor para um chat do telegram. Essa

Carlos Alberto 1 Apr 24, 2022