Team Members:
- Ilian Adeleke 2330261
- Cedric Augustin 2233427
PiGuardian is a smart IoT security and automation system built on Raspberry Pi OS.
It collects environmental data, detects motion intrusions, controls three IoT devices,
and displays everything through a cloud-deployed Flask dashboard (Render.com).
The system communicates using:
- MQTT → Adafruit IO (live sensor publishing + device control)
- REST → Neon PostgreSQL (historical storage + queries for charts)
- Flask + Chart.js (web dashboard with analytics)
- Render.com link https://piguardiandashboardrender.onrender.com/
- Link for github flask https://github.com/KylianLaw/PiGuardianDashboardRender.git
- Link for milestone 2 and .py files https://github.com/KylianLaw/milestone2IOT.git
| Component | Purpose |
|---|---|
| Raspberry Pi 4B | Main controller |
| DHT11 Sensor | Temperature + humidity |
| PIR Motion Sensor | Detects motion |
| I2C LCD 16×2 | Displays local system messages |
| LEDs (Red/Yellow/Green) | Device feedback |
| Buzzer (PWM) | Audible alerts |
| Breadboard + Wires | Circuit foundation |
| Pi Camera (optional) | Intrusion snapshots |
📌 INSERT REAL-WORLD WIRING PHOTO HERE

| Component | GPIO Pin | Notes |
|---|---|---|
| DHT11 | GPIO 19 | Data |
| PIR Sensor | GPIO 6 | Motion |
| LCD SDA | GPIO 2 | I²C |
| LCD SCL | GPIO 3 | I²C |
| Buzzer | GPIO 18 | PWM |
| LED Red | GPIO 20 | Output |
| LED Yellow | GPIO 16 | Output |
| LED Green | GPIO 21 | Output |
| File | Description |
|---|---|
environmental_module.py |
Reads DHT11, sends to Adafruit + Neon |
security_module.py |
PIR detection, intrusion logging |
device_control_module.py |
Sends device commands to Adafruit IO |
milestoneLastTry.py |
Main controller orchestrator |
MQTT_communicator.py |
Handles MQTT connection & publishing |
lcd.py, buzzer.py |
Local feedback via LCD + buzzer |
Stores:
- environmental_readings
- security_events
📌 INSERT TABLE STRUCTURE SCREENSHOT HERE

📌 INSERT LIVE DATA INSERT SCREENSHOT HERE

VERSION 2 with timestamp updated

VERSION 2 with timestamp updated

- Automatically writes to local SQLite if offline
- Sends data to Neon PostgreSQL when online
(We didnt implement offline sync )
sudo apt update && sudo apt upgrade -y
python3 milestoneLastTry.py
## Setup Instructions
### 1. OS Preparation
- Install Raspberry Pi OS (Bookworm or Bullseye).
- Enable I²C, Camera, and SSH using:
```bash
sudo raspi-config
sudo apt update && sudo apt upgrade -y
### 2. Install Dependencies
```bash
sudo apt install python3-pip python3-smbus i2c-tools -y
pip3 install paho-mqtt adafruit-circuitpython-dht adafruit-blinka- Edit your config.json and fill in your Adafruit credentials:
{ "ADAFRUIT_IO_USERNAME": "YourUser", "ADAFRUIT_IO_KEY": "YourKey" }
Run the main controller program:
python3 milestoneLastTry.py| Field | Type | Unit | Example |
|---|---|---|---|
| timestamp | string | ISO8601 | "2025-11-04T16:22:15" |
| temperature | float | °C | 22.7 |
| humidity | float | % | 55.2 |
| Field | Type | Description |
|---|---|---|
| motion_detected | bool | true when PIR triggered |
| smoke_detected | bool | not yet implemented |
| image_path | string | Local image or .txt fallback file |
Each day the system creates new files:
pip install -r requirements.txt
flask run📊 Data Formats
Environmental Readings:
| Field | Type | Example |
|---|---|---|
| timestamp | ISO8601 | "2025-11-27T16:22:15" |
| temperature | float | 24.6 |
| humidity | float | 45.1 |
Security Events:
| Field | Description |
|---|---|
| event_type | "motion" or "smoke" |
| raw_timestamp | ISO timestamp |
| image_path | optional camera capture |
| 🗂️ Daily Log Files (Auto Rotated) |
|---|
| YYYYMMDD_environmental_data.txt |
| YYYYMMDD_security_data.txt |
| YYYYMMDD_device_status.txt |
🌟 Future Work
- Add more sensors (CO₂, VOC, MQ-135)
- Real-time SMS or email alerts
- Face recognition
- Voice assistant control
- Advanced UI with animations
📝 Reflection
This project presented several challenges that required persistence and problem-solving. At the beginning, we were two weeks behind on Milestone 2 because our Raspberry Pi had not yet arrived, which created significant pressure on our schedule. Despite the delay, we managed to catch up by organizing our work efficiently and splitting tasks strategically between team members. Another major obstacle was dealing with Adafruit IO keys, which caused frequent issues with authentication and API access. At times, the keys would stop working unexpectedly, leaving us unable to push data or control devices until we regenerated credentials. We also ran into GitHub’s push-protection system, which blocked our commits because the configuration file accidentally contained sensitive keys. This forced us to redo commits, rewrite history, and re-structure our environment handling to protect the project. In the end, these difficulties helped us better understand secure development practices and made our system more robust and professional.








