A smart motion-detection security system using Raspberry Pi Pico (C SDK), Raspberry Pi (Python), Firebase, and an Android app (Jetpack Compose). The system captures and sends real-time images when motion is detected.
- 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).
- 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. - 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.
- MQTT broker option: Can host or relay MQTT messages for system control and status.
- 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.
[ PIR Sensor ] --> [ Pico (C SDK) ]
| |
| GPIO Signal (3.3V)
↓ ↓
[ LED + Buzzer ] [ Raspberry Pi (Python) ]
|
Captures Image
Uploads to Firebase
Sends FCM Notification
↓
[ Android App (Compose) ]
- Receives push alert
- Views image and timestamp
| 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) |
- 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/pico 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
- Install dependencies:
sudo apt update sudo apt install python3 python3-pip python3-opencv libatlas-base-dev libjasper-dev libqtgui4 libqt4-test - Clone repository:
git clone https://github.com/milutin2002/alarmSecuritySystem.git cd alarmSecuritySystem/pi - Install Python requirements:
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.










