Skip to content

A multi-task telegram bot that automates home devices with raspberry pi zero W and executes web-api tasks

License

Notifications You must be signed in to change notification settings

vorthkor/tempsense

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tempsense

A Telegram Bot that controls IOT devices on a Raspberry Pi Zero W and brings API data to the chat.

background: This project was first developed to monitor a server room's temperature using telegram bot to receive the values. As the time didn't help at that moment, I didn't finish the project. But now let's go.

Today it's a bot with multi-functions and programmable to receive more functions.

Materials:

  1. Any Raspberry Pi - I'm using Raspberry Pi Zero W on headless
  2. DHT11 temperature and humidity sensor
  3. BC548 Transistor
  4. 10k Ohms Resistor
  5. 5VDC Relay module - 110/220VCC
  6. Telegram Bot API token
  • Create with @BotFather on Telegram and it will give you the bot token
  • Enable inline commands and make the ones you want

Build system

Run pinout on raspberry's terminal to see which pin to connect - see map of the GPIO to see the connections.

  • Install pip
sudo apt install python3-pip
  • Install Adafruit DHT
pip3 install Adafruit_DHT
  • Install Telepot
pip3 install telepot
  • Install Python dotenv
pip3 install python-dotenv
  • Copy scripts to raspberry pi home
./tempsense/settg.sh
  • On Raspberry home, run ./start.sh to begin the application, ./stop.sh to stop and ./psaux.sh to check if the application stopped.

Now just chat with the bot or add it on a group or channel. Functions below!

I'm leaving the other files to further study, so just ignore them - or don't.

Soon more info.

Autostart on boot

  • Copy the service file to systemd directory
sudo cp tempsense.service /etc/systemd/system/
  • Test to see if the script runs (you can stop it too)
sudo systemctl start tempsense.service
  • Enable the autostart on boot
sudo systemctl enable tempsense.service

Any change on the system, remember to modify it on the service file.

Bot commands

  • /temperature - Verifies the room's temperature 🌡
  • /lumiere - Allumer la lampe 💡
  • /led - Accendere il LED 🔦
  • /naozhong - Dǎkāi nàozhōng ⏰
  • /fala - Conversas aletórias 🗣️
  • /miseru - 写真を見せる 📸
  • /dailyinfo - Info about the mars or astronomy picture of the day 📝
  • /astronomydaily - The astronomy picture of the day 🔭
  • /marsdaily - The latest mars picture 🚀
  • /listagem - Listagem de los comandos disponibles 📜
  • /whoami - 🗣️

extra: /update - updates within repository

Electronic schematic

This is the transistor BC548 used to toggle 3v3 to the input of the relay.


What's new

2023

  • Add echo function
  • Add dot env file - pass the token and chat ID there
  • Add alarms functions
  • Add new temperature function based on time
  • Allow only known IDs
  • Allow to update through git in outside network [in progress]

2022

  • New component -> relay (inside messages module).
  • Now you can control something through a command in Telegram, like a lamp, some system, etc.
  • In the way to do some IOT smart thing whatever.

2021

  • New script with Telegram bot. Interact with a bot to get temperature and humidity values.

References


WARNING: I don't know why, but if you add the bot already running in a group, the code AND the bot cracks, and it stops working forever, I lost like 4 bots doing that. If you know why please contact me or send and issue or PR i dunno. Thanks a lot!

Releases

No releases published

Packages

No packages published