Skip to content

milutin2002/alarmSecuritySystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔐 alarmSecuritySystem

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.

Features

Core

  • End-to-end alarm pipeline: Pico W detects motion → Raspberry Pi captures image → uploads to FirebaseAndroid 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).

Pico W (Firmware)

  • Wi-Fi powered by FreeRTOS (CYW43 + lwIP): Uses pico_cyw43_arch_lwip_sys_freertos so 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.

Raspberry Pi (Service)

  • 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.

Android (App)

  • 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.

🧠 Architecture Overview

[ 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

🛠️ Tech Stack

ComponentTech/Platform
MicrocontrollerRaspberry Pi Pico (C SDK)
Central ProcessingRaspberry Pi (Python 3)
CameraPi Camera / OpenCV
CloudFirebase Storage + Realtime DB
NotificationFirebase Cloud Messaging (FCM)
Mobile AppAndroid (Jetpack Compose, Kotlin)

🔧 Hardware Requirements

ComponentDescriptionImage
Raspberry Pi PicoMicrocontroller running C SDK for motion detection.Raspberry Pi Pico
Raspberry PiMain processing unit running Python scripts.Raspberry Pi
PIR Motion SensorDetects motion and triggers the Pico.PIR Sensor
LEDVisual motion detection indicator.LED
BuzzerAudible alert on motion detection.Buzzer
Pi CameraCaptures images when motion is detected.Pi Camera

📦 Installation

1️⃣ Raspberry Pi Pico (C SDK)

  • 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 .uf2 to the Pico by holding BOOTSEL and connecting via USB.
  • GPIO mapping:
    • PIR Sensor → GPIO17
    • LED → GPIO13
    • Buzzer → GPIO15
    • Signal to Pi → GPIO1

2️⃣ Raspberry Pi (Python)

  • 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 .env file:
    
    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
        

3️⃣ Android App (Jetpack Compose)

  • Open in Android Studio.
  • Add google-services.json to app/.
  • Enable Firebase Cloud Messaging and Realtime Database.
  • Subscribe to alerts topic for notifications.

🧪 Testing

  1. Move in front of the PIR sensor.
  2. Pico sends GPIO high to Pi.
  3. Pi captures and uploads image.
  4. Notification sent to phone.
  5. Tap notification to view event.

📸 Screenshots

Alarm in Real Life Android Receiving Notification
  • Raspberry Pi Capture
  • Android Event View
  • New ui
  • New ui

🧠 Goals

  • Embedded systems (C / FreeRTOS)
  • Python hardware control
  • Cloud integration
  • Mobile app development
  • Full-stack IoT architecture

📜 License

MIT License

🤝 Contributions

PRs and issues are welcome! Fork the repo and submit a pull request if you'd like to improve or extend the project.