Загрузка...

Raspberry Pi 5 Motion Detection Camera | Send Telegram Alerts with USB Webcam!

In this video, I show you how I built a real-time motion detection system using a Raspberry Pi 5 and a USB camera — complete with automatic Telegram notifications, instant video clips, and smart monitoring.

You’ll learn:

- How to connect and configure a USB webcam on Raspberry Pi 5
- Setting up motion detection using Python + motion feed detection
- Automatically recording video clips when motion is detected
- Sending alerts and video files directly to Telegram
- Tips for reliability, performance, and home surveillance use cases
- If you’re building a DIY security system or experimenting with Raspberry Pi automation, this tutorial is perfect for you.

🔧 Tools & Technologies Used:

Raspberry Pi 5
USB camera
Python + OpenCV
Telegram Bot API
Motion detection scripting

telegram helper:
https://t.me/userinfobot

Code:
import telegram
import os
import sys

# Configuration
BOT_TOKEN = 'HTTP API url'
CHAT_ID = 'xxxxxxxxxxxxxxxxxx'
VIDEO_DIR = '/var/lib/(dir name)'
def send_alert(video_file):
bot = telegram.Bot(token=BOT_TOKEN)
with open(video_file, 'rb') as f:
bot.send_message(chat_id=CHAT_ID, text="Motion detected!")
bot.send_video(chat_id=CHAT_ID, video=f)
if __name__ == '__main__':
latest_file = max([os.path.join(VIDEO_DIR, f) for f in os.listdir(VIDEO_DIR)], key=os.path.getctime)
send_alert(latest_file)
-------------------------------------------------------------------------------------------------
Delete videos from your Pi storage:

cd /var/lib/(your dir) || exit 1
find . -type f -name "*.mkv" -mmin +360 -delete

Видео Raspberry Pi 5 Motion Detection Camera | Send Telegram Alerts with USB Webcam! канала AronAyub
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять