Skip to content

Smart Field Patrolling & Hazard Detection Bot - Real-time monitoring dashboard with live camera feed, sensor data visualization, and interactive charts

License

Notifications You must be signed in to change notification settings

StarkAg/vigil-sense-dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿšจ VigilSense โ€“ Smart Field Patrolling & Hazard Detection Bot

Python Flask Arduino License

An intelligent IoT bot system with real-time hazard detection, live video streaming, person detection, and remote control capabilities

VigilSense combines Raspberry Pi, Arduino UNO R4 WiFi, and AI-powered computer vision to create a comprehensive monitoring and patrolling solution. Features include live camera streaming with YOLOv8 person detection, real-time sensor monitoring, hazard detection, and Bluetooth/WiFi-controlled motor system.


โœจ Features

๐ŸŽฅ Live Video & AI Detection

  • Real-time MJPEG streaming from Pi Camera v3
  • YOLOv8 person detection with bounding boxes
  • Live person count displayed on video feed
  • Responsive web interface with dark theme

๐Ÿ“Š Real-time Sensor Monitoring

  • Temperature & Humidity (DHT11)
  • Gas Detection (MQ sensor)
  • Flame Detection (Digital flame sensor)
  • Sound Detection (Microphone)
  • Vibration Detection (Analog sensor)
  • Color-coded alerts for hazard thresholds
  • Interactive sensor trend graphs (Chart.js)

๐Ÿค– Remote Motor Control

  • Bluetooth Low Energy (BLE) control via Bluefruit Connect app
  • WiFi web interface for browser control
  • 4-motor control with L293D driver
  • Speed control and directional commands
  • Real-time status feedback

๐Ÿ“ฑ Modern Web Dashboard

  • Premium dark theme with glassmorphism effects
  • Responsive design (mobile-friendly)
  • Fullscreen mode support
  • Detection log table with filtering
  • System status banner with alerts
  • No-scroll single-viewport layout

๐Ÿ”ง Hardware Integration

  • Raspberry Pi for video processing and web server
  • Arduino UNO R4 WiFi for sensor data and motor control
  • Pi Camera v3 for live video streaming
  • Multiple sensors for comprehensive monitoring

๐Ÿ“ธ Screenshots

Dashboard Main Main dashboard with live camera feed, sensor cards, and trend graphs

Detection Logs Detailed detection log table with timestamp and sensor readings


๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Raspberry Pi  โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚  Arduino UNO R4  โ”‚โ—„โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บโ”‚   Sensors    โ”‚
โ”‚                 โ”‚  Serial โ”‚   WiFi            โ”‚         โ”‚   & Motors   โ”‚
โ”‚  - Flask Server โ”‚         โ”‚  - Sensor Reader  โ”‚         โ”‚              โ”‚
โ”‚  - YOLOv8 AI    โ”‚         โ”‚  - Motor Control  โ”‚         โ”‚              โ”‚
โ”‚  - Pi Camera v3 โ”‚         โ”‚  - BLE/WiFi       โ”‚         โ”‚              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚
         โ”‚ HTTP/MJPEG Stream
         โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Web Browser    โ”‚
โ”‚  / Mobile App   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Quick Start

Prerequisites

  • Raspberry Pi (4B recommended) with Pi Camera v3
  • Arduino UNO R4 WiFi
  • L293D Motor Driver (1 or 2 chips)
  • 4 DC Motors
  • Sensors: DHT11, MQ Gas, Flame, Microphone, Vibration
  • Python 3.8+ on Raspberry Pi
  • Arduino IDE or Arduino CLI

1. Clone the Repository

git clone https://github.com/StarkAg/vigil-sense-dashboard.git
cd vigil-sense-dashboard

2. Install Dependencies

pip3 install --break-system-packages -r requirements.txt

3. Hardware Setup

Sensor Connections (Arduino)

  • DHT11 โ†’ Digital D4
  • Gas Sensor โ†’ Analog A0
  • Vibration โ†’ Analog A3
  • Flame Sensor โ†’ Digital D7
  • Microphone โ†’ Digital D9

See HARDWARE_SETUP.md for detailed wiring.

Motor Connections (Arduino)

  • Motor 1: IN1=D2, IN2=D3, ENA=D5
  • Motor 2: IN3=D4, IN4=D7, ENB=D6
  • Motor 3: IN1=D8, IN2=D9, ENA=D10
  • Motor 4: IN3=D11, IN4=D12, ENB=D13

See MOTOR_CONTROL_SETUP.md for details.

4. Upload Arduino Code

For Sensor Data Collection:

# Using Arduino IDE: Open arduino_code.ino and upload
# Or using Arduino CLI:
arduino-cli compile --fqbn arduino:renesas_uno:unor4wifi arduino_code/
arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:renesas_uno:unor4wifi arduino_code/

For Motor Control:

# Bluetooth version (recommended):
./upload_motor_control_ble.sh

# Or WiFi version:
./upload_motor_control.sh

5. Deploy to Raspberry Pi

# Automated deployment:
./deploy_to_pi.sh

# Or manually:
scp -r . pi@raspberrypi.local:~/vigil_sense_dashboard/
ssh pi@raspberrypi.local
cd ~/vigil_sense_dashboard
pip3 install --break-system-packages -r requirements.txt
python3 app.py

6. Access the Dashboard

Open your browser and navigate to:

http://raspberrypi-ip:8080

Or if running locally:

http://localhost:8080

๐Ÿ“š Documentation

Core Documentation

Control Interfaces

API Documentation

Camera Stream

GET /stream.mjpg

Returns MJPEG video stream with YOLOv8 person detection overlay.

Sensor Data

GET /api/sensors

Returns JSON:

{
  "temperature": 25.5,
  "humidity": 60.0,
  "gas": 450,
  "flame": 0,
  "sound": 1,
  "vibration": 512
}

Detection Logs

GET /api/logs

Returns array of last 10 detection entries.

System Status

GET /api/status

Returns:

{
  "status": "normal",
  "message": "โœ… All Systems Normal"
}

Person Count (YOLO)

GET /api/people

Returns:

{
  "count": 2,
  "yolo_enabled": true
}

๐ŸŽฎ Motor Control Commands

Bluetooth Commands (via Bluefruit UART)

  • forward / f / w - Move forward
  • backward / b / s - Move backward
  • left / l / a - Turn left
  • right / r / d - Turn right
  • stop / x - Stop all motors
  • speedup / + - Increase speed
  • speeddown / - - Decrease speed
  • speed:200 - Set speed (100-255)

WiFi Commands (via Browser)

  • Navigate to http://[arduino-ip]/forward
  • Or use the web interface controls

๐Ÿ› ๏ธ Technology Stack

Backend

  • Flask - Web framework
  • OpenCV - Image processing
  • Ultralytics YOLOv8 - Person detection
  • PySerial - Arduino communication
  • Gevent - Async server

Frontend

  • TailwindCSS - Styling (CDN)
  • Chart.js - Data visualization
  • Vanilla JavaScript - Real-time updates

Hardware

  • Raspberry Pi OS - Linux-based OS
  • Arduino UNO R4 WiFi - Microcontroller
  • rpicam-vid - Pi Camera v3 streaming
  • L293D - Motor driver

๐Ÿ“ Project Structure

vigil_sense_dashboard/
โ”œโ”€โ”€ app.py                          # Flask backend with YOLO
โ”œโ”€โ”€ requirements.txt                 # Python dependencies
โ”œโ”€โ”€ templates/
โ”‚   โ”œโ”€โ”€ index.html                  # Main dashboard
โ”‚   โ””โ”€โ”€ logs.html                   # Detection logs page
โ”œโ”€โ”€ static/
โ”‚   โ”œโ”€โ”€ css/
โ”‚   โ”‚   โ””โ”€โ”€ style.css              # Custom styles
โ”‚   โ””โ”€โ”€ js/
โ”‚       โ””โ”€โ”€ dashboard.js           # Frontend logic
โ”œโ”€โ”€ arduino_code.ino                # Sensor data collection
โ”œโ”€โ”€ arduino_motor_control_ble.ino  # Bluetooth motor control
โ”œโ”€โ”€ arduino_motor_control.ino      # WiFi motor control
โ”œโ”€โ”€ deploy_to_pi.sh                 # Deployment script
โ”œโ”€โ”€ upload_motor_control*.sh       # Motor control upload scripts
โ””โ”€โ”€ docs/
    โ”œโ”€โ”€ HARDWARE_SETUP.md
    โ”œโ”€โ”€ ARDUINO_SETUP.md
    โ”œโ”€โ”€ MOTOR_CONTROL_SETUP.md
    โ””โ”€โ”€ ...

๐Ÿ”ง Configuration

WiFi Credentials (Arduino Motor Control)

Edit arduino_motor_control.ino:

const char* ssid = "YourWiFiName";
const char* password = "YourPassword";

Sensor Thresholds (Flask)

Edit app.py to adjust alert thresholds:

# Hazard detection thresholds
TEMP_THRESHOLD = 35.0
GAS_THRESHOLD = 500

Camera Settings

Modify init_camera() in app.py:

'--width', '1280',
'--height', '720',
'--framerate', '30',

๐Ÿ› Troubleshooting

Camera Not Streaming

# Kill any existing camera processes
pkill -9 rpicam-vid

# Restart the dashboard
python3 app.py

Arduino Not Detected

# Check serial port
ls /dev/ttyACM* /dev/ttyUSB*

# Test connection
python3 test_arduino.py

YOLO Model Not Loading

# Install ultralytics
pip3 install --break-system-packages ultralytics

# First run will download model (~6MB)

Bluetooth Connection Issues

  • Ensure Arduino code is uploaded
  • Check Serial Monitor for "BLE initialized"
  • Restart Bluefruit Connect app
  • Verify phone Bluetooth is enabled

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ‘ค Author

StarkAg


๐Ÿ™ Acknowledgments

  • Ultralytics for YOLOv8 model
  • Adafruit for Bluefruit Connect app
  • Arduino community for hardware support
  • Raspberry Pi Foundation for Pi Camera support

๐Ÿ“Š Project Status

Status Maintenance

Current Version: 2.0

  • โœ… Live video streaming with YOLOv8
  • โœ… Real-time sensor monitoring
  • โœ… Bluetooth motor control
  • โœ… WiFi motor control
  • โœ… Comprehensive documentation
  • ๐Ÿ”„ Active development

๐ŸŒŸ Star History

If you find this project useful, please consider giving it a star โญ!


Made with โค๏ธ for IoT and Robotics enthusiasts

About

Smart Field Patrolling & Hazard Detection Bot - Real-time monitoring dashboard with live camera feed, sensor data visualization, and interactive charts

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published