InstUpd - project for Instant Updates on demand that allows you to send a camera shot and create a stream from your Raspberry Pi Zero 2 W via a bot.
- Capture photos remotely via Telegram bot
- Start and stop video streaming on demand
- Access video stream through a web page
- Remote access via ngrok tunneling
- Raspberry Pi Zero 2 W with OS installed and connected to WiFi
- USB webcam compatible with Raspberry Pi (you may need to use a Micro-B Male to A Female OTG Cable)
- Telegram API key (for bot integration) - create a new bot using BotFather on Telegram
- ngrok API key and static domain (for remote access) - sign up on the ngrok website and create a static domain (1 for free)
- Install Rust on your PC. Follow the instructions on the official website.
- Install RoboPLC framework on your PC. Follow the instructions on the official website.
- Add target to your Rust toolchain:
rustup target add aarch64-unknown-linux-gnu
For macOS:
Install cross
. Documentation here:
cargo install cross --git https://github.com/cross-rs/cross
- Install RoboPLC Manager on your Raspberry Pi Zero 2 W. Follow the instructions on the official website.
- Update the env file, filled by .env.example file on Raspberry Pi - path
/etc/roboplc/program.env
. - Set a static IP for Raspberry Pi Zero 2 W on your router.
- Isolate CPUs for the RoboPLC Manager process. Follow these instructions.
- Increase swap size on Raspberry Pi Zero 2 W.
- To run the project on Raspberry Pi Zero 2 W, you need to build it on your PC and flash it to Raspberry Pi Zero 2 W. (Specify IP address in local network in file)
robo flash -r -f
- Interact with your Telegram bot using the following commands:
/help
— List available commands/photo
— Get a photo from the camera/getvideo
— Get a URL with video stream/stopvideo
— Stop video stream
The project consists of several key components:
camera.rs
: Handles camera operations and frame capture.telegram_bot.rs
: Implements the Telegram bot functionality.ws_server.rs
: Manages the WebSocket server for video streaming.core.rs
: Defines core data structures and configurations.
- Only authorized users (defined in
TELEGRAM_ALLOWED_USER_IDS
var) can interact with the bot. - The admin user (defined by
TELEGRAM_ADMIN_USER_ID
) receives notifications about bot activities. - ngrok is used for secure tunneling, allowing remote access to the video stream.
- If the camera is not detected, ensure it's properly connected and compatible with Raspberry Pi Zero 2 W.
- If ngrok fails to start, check your authentication token and internet connection. Note that data transfer limits on the Free account are 1GB per month by default.
- For other issues, check the application logs (set
RUST_LOG=debug
for more detailed logging).
The following features are planned for future development:
- Add a tests
- Add a more documentation
- Fine-tune the WebSocket server
- Transition to a real-time operating system
- Integrate with Home Assistant for smart home functionality
Contributions are welcome! Please feel free to submit a Pull Request.