Are you running this on a or a Raspberry Pi ?
This guide explains how to set up free surveillance by connecting your to Telegram , allowing you to receive real-time motion alerts, snapshots, and video clips directly to your phone without subscription fees. Why Connect IPCam to Telegram? Free Notifications: No monthly cloud storage fees.
To connect the camera feed to the Telegram API for free, select the method that best matches your technical comfort level. Method 1: Using No-Code Software (ContaCam or Agent DVR) ipcam telegram free
Sent photos and videos remain in your chat history indefinitely.
import cv2 import requests import time # Configuration TOKEN = "YOUR_BOT_TOKEN" CHAT_ID = "YOUR_CHAT_ID" CAMERA_URL = "http://192.168.1" # Replace with your stream URL def send_telegram_photo(image_path): url = f"https://telegram.orgTOKEN/sendPhoto" with open(image_path, 'rb') as photo: files = 'photo': photo data = 'chat_id': CHAT_ID, 'caption': '⚠️ Motion Alert detected!' requests.post(url, files=files, data=data) # Initialize camera cap = cv2.VideoCapture(CAMERA_URL) ret, frame1 = cap.read() ret, frame2 = cap.read() while cap.isOpened(): # Calculate difference between frames to detect movement diff = cv2.absdiff(frame1, frame2) gray = cv2.cvtColor(diff, cv2.COLOR_BGR2GRAY) blur = cv2.GaussianBlur(gray, (5, 5), 0) _, thresh = cv2.threshold(blur, 20, 255, cv2.THRESH_BINARY) dilated = cv2.dilate(thresh, None, iterations=3) contours, _ = cv2.findContours(dilated, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) for contour in contours: if cv2.contourArea(contour) < 5000: # Adjust sensitivity here continue # Motion triggered cv2.imwrite("alert.jpg", frame2) send_telegram_photo("alert.jpg") time.sleep(10) # Cooldown period to avoid spamming alerts frame1 = frame2 ret, frame2 = cap.read() cap.release() Use code with caution. Optimizing Your DIY Security Setup Are you running this on a or a Raspberry Pi
: Video streaming and motion detection drain batteries fast. Use a long charging cable. Wi-Fi Stability
Tell me your details, and I can give you the exact steps for your camera model. Share public link Free Notifications: No monthly cloud storage fees
: Ensure the old phone has a strong connection to your home router.