Giter Club home page Giter Club logo

picodoorbell's Introduction

PicoDoorBell

Doorbell notifier powered by Raspberry Pi Pico W and Telegram.

License


Setting up the project

This project works by sending a notification through a Telegram bot. You could send it directly to your user or a group/channel.

Hardware list

  • 01 Raspberry Pi Pico W
  • 01 25v to 5v DC-Stepdown converter
  • 01 N-Type Transistor
  • Your doorbell :D Mine is a Ritto Twinbus 7630 indoor.

DISCLAIMER: Even though this project works fine for me and with my specific doorbell, it doesn't mean it will work with any system. This project does not come with any guarantee whatsoever. If you want to implement this, do it at your own responsibility and risk.

Schematics

Getting the code

Clone this repository and make the necessary changes as stated in the following sections.

IDE

I have used the Thonny IDE, version 3.3.13, to code this project. You can download it here.

Alternatively, if you're coding on a Raspberry Pi system, you can run on your terminal:

sudo apt update && sudo apt install thonny

Setup the Micropython environment

If your Raspberry Pi Pico W is already flashed with MicroPython, skip to the next step. Otherwise:

  • Download the latest Pico W EF2 file here - Please note this only works with the Raspberry Pi Pico W. If you have the board without Wi-Fi do not flash it with this file.
  • Before plugging your Pico into your computer, locate and press the BOOTSEL button on the board and hold it.
  • With the button still pressed, connect your device. It should mount as a mass storage device on your computer, named PI-RP2.
  • Drag and drop the EF2 file into the PI-RP2 storage. After it finishes copying, it will automatically unmount from your computer. Don't worry when it does; this is entirely normal.
  • And you're done. Your Pico W is now ready to run MicroPython code :)

For more information, please check the official documentation on the Raspberry Pi Foundation website.

Setup Thonny with your Pico W

After flashing your Pico W with MicroPython, make sure it's connected to your computer, open Thonny, and then click on the bottom right corner of the IDE. Choose "MicroPython (Raspberry Pi Pico)" in the drop-down menu.

For more information on setting up Thonny, please see the official documentation here.

Adding the code to your Pico W

After setting everything up, all you need to do is copy & paste the contents of the main.py file into Thonny and save it. Do the same with the secrets.py file. But don't run the code just yet. We still need to create a bot on Telegram and change the placeholders in the secrets.py file.

Setting up the Wi-Fi

The code on main.py is already handling the Wi-Fi network connection. All you need to do is replace both the ssid and pw inside the secrets.py file with your network name and password, respectively.

Setting up the Telegram bot

Since this project works on top of Telegram, we need to create a bot for it.

First of all, open Telegram and find the BotFather. Or click here to be redirected to it.

As stated in the official documentation, do the following after starting the chat with the BotFather:

Use the /newbot command to create a new bot. The BotFather will ask you for a name and username, then generate an authentication token for your new bot.

The name of your bot is displayed in contact details and elsewhere.

The username is a short name to be used in mentions and t.me links. Usernames are 5-32 characters long and are case insensitive but may only include Latin characters, numbers, and underscores. Your bot's username must end in 'bot', e.g. 'tetris_bot' or 'TetrisBot'.

The token is a string along the lines of 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw that is required to authorize the bot and send requests to the Bot API. Anyone can use it to control your bot. Keep your token secure and store it safely.

Get the generated token and replace it inside secrets.py under the botToken key.

Choosing where to send the messages

Now choose if you want to send the notifications directly as a DM or through a channel on Telegram.

Sending the notification as a DM

To make the bot send a message to yourself, you first need to send a message to it. Otherwise, it won't be able to send you any messages. This must before anything else. After you send the message, you need to get your user ID on Telegram. To do so, use this bot.; once it answers you, get the ID and replace it under the telegramDmUid key inside the secrets.py file.

Sending the notification in a channel

You can also use a Telegram channel to relay notifications to many users. First, you must create the Telegram channel and add anyone who may want to receive the alerts. Also, add your bot to this channel as an Admin. After setting everything up, send a message on your channel so your bot can "see it."

Now you need to get the channel ID. To do so, Go to https://api.telegram.org/bot{TOKEN}/getUpdates and replace {TOKEN} with your bot's token. The URL will show you a JSON response with all the messages in this channel and the channel details. Please locate the channel ID inside this response. The ID should start with a minus symbol (-). Copy that ID and replace it under the telegramDmUid key inside the secrets.py file.

For more information on any of the steps above, please refer to the official Telegram Bot Documentation.


When you have all the placeholders replaced inside secrets.py, you may run the code on Thonny. Have fun! :)

Final details

  • The GPIO that I used as an input to detect the button press was GP18, you may chose a different one to fit your project. You can change that inside main.py.
  • You can also send the startup and alert message inside main.py, look for the variables named startupText and text.

picodoorbell's People

Contributors

mauker1 avatar

Stargazers

Paulsenik avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.