All Projects → scaidermern → piCamBot

scaidermern / piCamBot

Licence: GPL-3.0 license
Security camera based on a raspberry pi and Telegram, controllable by smartphone

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to piCamBot

Rpicam
Raspberry PI Surveillance Automation
Stars: ✭ 77 (+79.07%)
Mutual labels:  surveillance, motion
room-glimpse
Read what your Raspberry Pi sees (picamera + Azure Cognitive / IoT)
Stars: ✭ 15 (-65.12%)
Mutual labels:  motion, pi-camera
Pai
Paradox Magellan, Spectra and EVO, with MQTT, Signal, Pushbullet, Pushover and others
Stars: ✭ 185 (+330.23%)
Mutual labels:  surveillance
Jovian
Metagenomics/viromics pipeline that focuses on automation, user-friendliness and a clear audit trail. Jovian aims to empower classical biologists and wet-lab personnel to do metagenomics/viromics analyses themselves, without bioinformatics expertise.
Stars: ✭ 14 (-67.44%)
Mutual labels:  surveillance
Juicer
Juicer is a generic animation / motion library for macOS & iOS & tvOS written in Swift
Stars: ✭ 13 (-69.77%)
Mutual labels:  motion
Viseron
Self-hosted NVR with object detection
Stars: ✭ 192 (+346.51%)
Mutual labels:  surveillance
android-stalkerware
Various analysis of Android stalkerware
Stars: ✭ 88 (+104.65%)
Mutual labels:  surveillance
Personal Security Checklist
🔒 A curated checklist of 300+ tips for protecting digital security and privacy in 2021
Stars: ✭ 2,388 (+5453.49%)
Mutual labels:  surveillance
rc-headless-transmitter
DIY 2.4 GHz RC transmitter without display, configurable through smartphone or web browser
Stars: ✭ 28 (-34.88%)
Mutual labels:  smartphone
DIY-ai-art
How to build your own AI art installation from scratch
Stars: ✭ 556 (+1193.02%)
Mutual labels:  pir-sensor
ReactZooApp
ReactZooApp
Stars: ✭ 33 (-23.26%)
Mutual labels:  motion
use-spring
Hooke's law hook
Stars: ✭ 53 (+23.26%)
Mutual labels:  motion
Acurustrack
A multi-object tracking component. Works in the conditions where identification and classical object trackers don't (e.g. shaky/unstable camera footage, occlusions, motion blur, covered faces, etc.). Works on any object despite their nature.
Stars: ✭ 196 (+355.81%)
Mutual labels:  surveillance
FreePhone
FreePhone es un proyecto de investigación sobre privacidad en dispositivos móviles. Con este repositorio pretendemos liberar toda la experiencia acumulada durante la creación de un smartphone casero.
Stars: ✭ 57 (+32.56%)
Mutual labels:  smartphone
Vanillarat
VanillaRat is an advanced remote administration tool completely coded in C# for Windows.
Stars: ✭ 192 (+346.51%)
Mutual labels:  surveillance
dynamic-motion
Provide additional functionality to Android MotionLayout.
Stars: ✭ 34 (-20.93%)
Mutual labels:  motion
Sormas Project
SORMAS (Surveillance, Outbreak Response Management and Analysis System) is an early warning and management system to fight the spread of infectious diseases.
Stars: ✭ 183 (+325.58%)
Mutual labels:  surveillance
Privacytools.io
🛡🛠 You are being watched. Protect your privacy against global mass surveillance.
Stars: ✭ 3,048 (+6988.37%)
Mutual labels:  surveillance
opensim-moco
Solve optimal control problems for musculoskeletal models using OpenSim and direct collocation.
Stars: ✭ 45 (+4.65%)
Mutual labels:  motion
ESPproMon
ESPproMon © Smartphone App for Energy Monitoring with Appp © Technology
Stars: ✭ 15 (-65.12%)
Mutual labels:  smartphone

piCamBot

Security camera based on a Raspberry Pi and Telegram, controllable via smartphone and computer.

Description

This is a simple Telegram bot that acts as a security camera. It is intented to run on a Raspberry Pi but may be used on any other Linux system, too. It requires a camera (for example a Raspberry Pi Camera Module v2) and either a PIR sensor or the software motion. It can be controlled by any Telegram client, thus supporting many different client platforms such as smartphones (Android, iOS and Windows Phone) and computers (Linux, macOS and Windows).

Requirements

  • Raspberry Pi with Raspberry Pi OS (recommended, but works on any other Linux system with some adjustments)
  • Camera (e.g. Raspberry Pi Camera Module v2)
  • PIR sensor (e.g. HC-SR501) or motion software (using the PIR sensor is recommended, it works way better than using motion software)
  • Piezo buzzer (optional)
  • Telegram account and a Telegram bot
  • python (version 3):

To install the necessary software on Raspberry Pi OS, Debian or a similar distribution use the following commands:

  • as root:
    • apt install python3-rpi.gpio (optional, for PIR or buzzer support)
    • apt install python3-pip
  • as regular user:
    • pip3 install python-telegram-bot inotify

Configuration

Copy config.json.example to config.json and open it for editing. In section telegram enter your Telegram token and owner_ids. See these instructions for obtaining your Telegram user ID. Alternatively just add your Telegram token and a random owner ID, run piCamBot and send a message to your bot. piCamBot will log messages from unknown users and write out their user IDs.

If you aren't using a Raspberry Pi then you need to change pir:capture_cmd and capture:cmd to use a different command than raspistill.

Either enable pir (when using a PIR sensor) or motion (when no PIR sensor is available). It is highly recommended to use a PIR sensor since it works better than motion in my experience.

Note: You can't enable pir and motion at the same time. However you can disable both and still use piCamBot to perform manual camera captures.

1a) Configuration using a PIR sensor

Set a correct pir:gpio port. You can use python3 test_pir.py to check if the PIR is working and a correct gpio port has been configured.

1b) Configuration using motion software

Note: It is highly recommended to use a PIR sensor instead. The code for using motion instead is not really maintained. Also, in most cases a PIR sensor works way better than motion.

Check that the pid_file path is correct. It must match the process_id_file setting in your motion.conf. Also check that general:image_dir matches your motion.conf's target_dir. Edit motion.conf and adjust rotate, width, height to your camera. Also adjust threshold and noise_level to your environment (good luck with that...). daemon mode must be enabled for piCamBot!

Ideally run motion separately to adjust all these settings until it matches your expected results. Afterwards try to use it with piCamBot.

2) Configuring a buzzer

You can enable acoustic alarms, e.g. with a piezo buzzer. Enable the buzzer via buzzer:enable and set buzzer:gpio accordingly. You can also define custom buzzer sequences for various actions. To see if the buzzer is working and the correct gpio port has been set you can run python3 test_buzzer.py or send the /buzzer command.

Optional: Use a tmpfs for captured images

Especially when using a Raspberry Pi it is a good idea to write captured images to a tmpfs. This increases the lifespan if your sdcard. Using the standard configuration piCamBot writes its captures to /tmp/piCamBot/. To mount /tmp/ as tmpfs add the following line to your /etc/fstab:

tmpfs           /tmp            tmpfs   nosuid,size=25%   0       0

After a reboot /tmp/ should be mounted as tmpfs.

3) Using LED(s) during capture

To improve image quality during low light you can turn on LED(s) during image capture. Enable capture:led:enable and set capture:led:gpio accordingly.

LEDs can also be turned on and off explicitly by using the command /ledtoggle.

Starting the bot

Execute python3 piCamBot.py as a regular user, i.e. non-root. The bot will automatically send a greeting message to all owners if Telegram access is working. For troubleshooting take a look at its log files inside the piCamBot directory.

Autostart

It is recommended to start the bot automatically after boot, e.g. via a crontab entry or init script. Here is an example for starting the bot automatically at boot inside a tmux session, via cron (crontab -e as a regular user, i.e. non-root):

@reboot              cd ~/picambot && SHELL=/bin/bash tmux new -d -s picambot "python3 piCamBot.py"

You can attach to it via tmux a -t picambot and detach from it via the default key binding ctrl-b d.

There is also a shell script which automatically restarts the bot on fatal errors: piCamBotLoop.sh. To use it, just run this shell script instead of the python script. You can also add it to cron, of course (as an alternative to the previous example, don't add both!):

@reboot              cd ~/picambot && SHELL=/bin/bash tmux new -d -s picambot "./piCamBotLoop.sh"

Controlling the bot

The bot will start with motion-based capturing being disabled.

After enabing motion-based capturing it will either react on the PIR sensor and performs captures whenever a motion is reported. Or it reacts on captures performed by the motion software. In either case, captured images are sent via Telegram to all owners. Afterwards these images are deleted from the disk. You can control this behavior via config option general:delete_images.

You can use /help to list the available commands:

  • /arm: Starts motion-based capturing. If motion software is enabled it will be started as well.
  • /disarm: Stops motion-based capturing. If motion software is enabled it will be stopped as well.
  • /status: Reports whether motion-based capturing is currently enabled.
  • /capture: Takes a manual capture with the camera. If motion-based capturing and motion software is enabled it will be temporarily stopped and started again after the capture. This is needed since access to the camera is exclusive.
  • /kill: Only to be used if motion software is enabled. This kills the software (using SIGKILL) in case it is running and /disarm fails to stop it.
  • /ledtoggle: Toggle capture LED, if configured.
  • /ledstatus: Show state of capture LED (on/off), if configured.
  • /buzzer: Trigger buzzer, if configured.
  • /log: Show recent log messages.
  • /help: Shows a list of supported commands.

Examples

Example conversation with the Telegram bot

Example Raspberry Pi based security cam with PIR sensor

License

GPL v3 (c) Alexander Heinlein

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].