Designed and implemented an IoT security camera system using Raspberry Pi Pico (C SDK), Raspberry Pi (Python/Flask), Firebase, and Android (Jetpack Compose). The system performs real-time motion detection with instant mobile alerts and snapshots, supports live video streaming via a Flask server, and allows remote camera pan control from the Android app through a Pico-driven motorized mount.
- End-to-end alarm pipeline: Pico W detects motion → Raspberry Pi captures image → uploads to Firebase → Android app receives a push and displays the evidence.
- Remote control via MQTT: The system can be armed or disarmed through MQTT messages (e.g., from the Android app).
- Integrated live surveillance: Real-time camera streaming to the Android app from the Raspberry Pi Flask server.
- Motorized pan control: Users can remotely rotate the camera from the mobile UI; commands propagate Pi → Pico W → motor driver
- Wi-Fi powered by FreeRTOS (CYW43 + lwIP): Uses
pico_cyw43_arch_lwip_sys_freertosso Wi-Fi and networking tasks run under FreeRTOS while main logic stays simple. - MQTT client support: Subscribes to a control topic (e.g.,
pico/alarm/set) to toggle system state and publishes status updates. - Motorized camera rotor control: Drives the pan motor via GPIO/PWM, executing rotation commands received over MQTT from the Raspberry Pi/Android app.
- Station mode (WPA2): Auto-connects and reconnects to configured Wi-Fi SSID.
- Configurable credentials: SSID/password and MQTT broker address defined in a config header or build-time defines.
- Capture on trigger: Listens for Pico W GPIO or network signal and captures an image (OpenCV / Pi Camera).
- Cloud upload: Saves images to Firebase Storage and writes metadata to Realtime Database.
- Push notifications: Sends FCM alerts to Android clients with image and timestamp.
- Flask live streaming server: Provides real-time MJPEG/HTTP video stream consumed by the Android app for live surveillance.
- Realtime alerts: Receives Firebase Cloud Messaging notifications on motion events.
- System control: Sends MQTT messages to arm/disarm the alarm remotely.
- Evidence viewer: Displays captured images and event details.
- Live surveillance: Streams real-time video from the Raspberry Pi Flask server directly in the app.
- Remote camera rotation: Provides on-screen controls to rotate the camera; commands are sent via MQTT to the Raspberry Pi → Pico W motor controller.
[ PIR Sensor ] ───▶ [ Pico W (C SDK + FreeRTOS) ]
| |
| GPIO (3.3V) | MQTT (status/events)
↓ ↓
[ LED + Buzzer ] [ Raspberry Pi (Python + Flask + MQTT) ]
| |
Camera Capture MQTT Bridge
+ Live Stream + Device Control
| |
Uploads to Firebase |
Sends FCM Alert |
↓ |
[ Android App (Compose) ]
- Receives push alert
- Views images/events
- Live video stream
- Rotate camera (pan)
|
| MQTT command
↓
[ Pico W Motor Driver ]
|
↓
[ Camera Rotor ]
| Component | Tech/Platform |
|---|---|
| Microcontroller | Raspberry Pi Pico (C SDK) |
| Central Processing | Raspberry Pi (Python 3) |
| Camera | Pi Camera / OpenCV |
| Cloud | Firebase Storage + Realtime DB |
| Notification | Firebase Cloud Messaging (FCM) |
| Mobile App | Android (Jetpack Compose, Kotlin) |
| Http live server | Python flask server |
- Install the Pico SDK and CMake:
sudo apt update sudo apt install cmake gcc-arm-none-eabi build-essential git - Clone and set up the Pico SDK:
git clone https://github.com/raspberrypi/pico-sdk.git --branch master export PICO_SDK_PATH=$PWD/pico-sdk - Clone this project and build:
git clone https://github.com/milutin2002/alarmSecuritySystem.git cd alarmSecuritySystem/AlarmSysten mkdir build && cd build cmake -DWIFI_SSID="wifi_name" -DWIFI_PASS="wifi_password" .. make - Flash the generated
.uf2to the Pico by holding BOOTSEL and connecting via USB. - GPIO mapping:
- PIR Sensor → GPIO17
- LED → GPIO13
- Buzzer → GPIO15
- Signal to Pi → GPIO1
- Rotor to pico → GPIO12
- Install dependencies:
sudo apt update sudo apt install python3 python3-pip python3-opencv libatlas-base-dev libjasper-dev libqtgui4 libqt4-test sudo apt install -y libcamera-apps libcamera-dev python3-libcamera sudo apt install libcap-dev -y - Clone repository:
git clone https://github.com/milutin2002/alarmSecuritySystem.git cd alarmSecuritySystem/PI - Install Python requirements:
python3 -m venv --system-site-packages venv source venv/bin/activate pip3 install -r requirements.txt - Create a
.envfile:FIREBASE_CRED_PATH=your_service_account.json FIREBASE_BUCKET=your-bucket-name.appspot.com FIREBASE_DB=https://your-db.firebaseio.com API_KEY=your_fcm_key (if needed) - Run script:
python3 main.py - Enable camera:
sudo raspi-config # Interface Options -> Enable Camera
- Open in Android Studio.
- Add
google-services.jsontoapp/. - Enable Firebase Cloud Messaging and Realtime Database.
- Subscribe to
alertstopic for notifications.
- Move in front of the PIR sensor.
- Pico sends GPIO high to Pi.
- Pi captures and uploads image.
- Notification sent to phone.
- Tap notification to view event.
- Embedded systems (C / FreeRTOS)
- Python hardware control
- Cloud integration
- Mobile app development
- Full-stack IoT architecture
MIT License
PRs and issues are welcome! Fork the repo and submit a pull request if you'd like to improve or extend the project.












