Skip to content
AhqafCoderPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

28 Commits

Folders and files

Repository files navigation

🌊 Autonomous Water Quality Monitoring Boat

Smart India Hackathon 2025 Team Gandharvas Invertis University

An intelligent autonomous robotic boat designed for real-time water quality monitoring, plastic pollution detection, and algae bloom identification using advanced AI/ML models and hyperspectral sensing technology.

Boat System


πŸ“‹ Table of Contents


🎯 What This Project Does

This autonomous boat system:

  1. Navigates autonomously through water bodies using GPS waypoints
  2. Monitors water quality in real-time using an 18-channel hyperspectral sensor
  3. Detects plastic pollution using computer vision (YOLOv8)
  4. Identifies algae blooms and predicts chlorophyll-A levels using machine learning
  5. Operates offline-first with automatic cloud synchronization when internet is available
  6. Provides real-time dashboard for monitoring and remote control
  7. Collects samples at specified locations using an automated pump system

🚨 Problem Statement & Solution

Problem

Water pollution is a critical environmental challenge affecting lakes, rivers, and oceans globally:

  • Plastic Pollution: 8+ million tons of plastic enter oceans annually, harming marine life
  • Algae Blooms: Harmful algal blooms (HABs) contaminate drinking water and kill aquatic life
  • Manual Monitoring: Traditional water quality testing is time-consuming, expensive, and covers limited areas
  • Limited Data: Lack of continuous, real-time water quality data for effective decision-making

Our Solution

An autonomous robotic boat that combines:

βœ… AI-Powered Detection: Dual AI system for plastic detection (YOLOv8) and chlorophyll prediction (CatBoost)
βœ… Hyperspectral Sensing: 18-channel spectral sensor (410-940nm) for detailed water analysis
βœ… Offline-First Architecture: Works without internet, syncs data when connected
βœ… Cost-Effective: Uses affordable hardware (Raspberry Pi + ESP32) compared to commercial solutions
βœ… Scalable: Can deploy multiple boats to cover large water bodies
βœ… Real-Time Monitoring: Live dashboard with GPS tracking and data visualization

Impact

  • Early detection of harmful algal blooms
  • Mapping plastic pollution hotspots
  • Continuous water quality monitoring for environmental agencies
  • Data-driven decision making for water resource management

✨ Key Features

πŸ€– Autonomous Navigation

  • GPS-based waypoint navigation
  • IMU and magnetometer for orientation
  • Obstacle avoidance capabilities
  • Return-to-home functionality
  • Mission planning with custom routes

πŸ”¬ Advanced Sensing

  • AS7265x Spectral Sensor: 18 channels from 410nm to 940nm
  • Pi Camera NoIR: Visual documentation and plastic detection
  • GPS NEO-6M: Position tracking with 2.5m accuracy
  • MPU6050 IMU: Pitch/roll compensation
  • HMC5883L Magnetometer: Heading calculation
  • TDS Sensor: Total dissolved solids measurement

🧠 Dual AI System

Macro AI (Plastic & Algae Detection)

  • YOLOv8n model trained on 5000+ images
  • Detects plastic bottles, bags, and algae blooms
  • Real-time inference on camera feed
  • 70+ training epochs for high accuracy

Micro AI (Chlorophyll Prediction)

  • CatBoost regression model
  • Predicts chlorophyll-A concentration from spectral data
  • SHAP explainability for model interpretability
  • Trained on calibrated spectral measurements

🌐 Connectivity & Communication

  • MQTT protocol for real-time updates
  • Offline SQLite database with cloud sync
  • WebSocket for live dashboard updates
  • RESTful API for data access
  • MongoDB cloud storage

πŸ“Š Web Dashboard

  • Real-time boat tracking on interactive map
  • Live sensor data visualization
  • Mission management interface
  • Historical data analysis with charts
  • Remote control capabilities
  • Alert system for anomalies

πŸ”‹ Power Management

  • Battery voltage monitoring
  • Low-power modes
  • Automatic shutdown on critical battery
  • Solar charging support (optional)

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   CLOUD BACKEND                         β”‚
β”‚  Express.js + MongoDB + MQTT Broker + WebSocket        β”‚
β”‚  β€’ Mission management                                   β”‚
β”‚  β€’ Data storage & analytics                             β”‚
β”‚  β€’ Real-time updates                                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚ MQTT/HTTPS
                        β”‚ (when online)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚             RASPBERRY PI 4 (Master Controller)          β”‚
β”‚  Python + SQLite + MQTT Client                          β”‚
β”‚  β€’ Navigation & Mission Control                         β”‚
β”‚  β€’ Sensor Data Acquisition                              β”‚
β”‚  β€’ AI Inference (Chlorophyll + Plastic)                 β”‚
β”‚  β€’ Local Database & Sync Service                        β”‚
β”‚                                                          β”‚
β”‚  Sensors:                                               β”‚
β”‚  β€’ AS7265x (IΒ²C) - 18-channel spectral                 β”‚
β”‚  β€’ Pi Camera NoIR - Image capture                       β”‚
β”‚  β€’ NEO-6M GPS - Position                                β”‚
β”‚  β€’ MPU6050 - IMU                                        β”‚
β”‚  β€’ HMC5883L - Magnetometer                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚ USB Serial
                        β”‚ (115200 baud)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              ESP32 (Motor Controller)                   β”‚
β”‚  Arduino C++ Firmware                                   β”‚
β”‚  β€’ Controls 2Γ— DC motors (L298N)                        β”‚
β”‚  β€’ Controls 1Γ— peristaltic pump                         β”‚
β”‚  β€’ Battery voltage monitoring                           β”‚
β”‚  β€’ Receives commands from RPi                           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚                β”‚
          β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
          β”‚  L298N #1 β”‚    β”‚ L298N #2 β”‚
          β”‚  Left +   β”‚    β”‚   Pump   β”‚
          β”‚  Right    β”‚    β”‚  Motor   β”‚
          β”‚  Motors   β”‚    β”‚          β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Technologies Used

Hardware

  • Raspberry Pi 4 (4GB RAM) - Main controller
  • ESP32 DevKit - Motor controller
  • AS7265x - 18-channel spectral sensor (Triad Spectroscopy)
  • Pi Camera NoIR - Near-infrared camera
  • NEO-6M GPS - Global positioning
  • MPU6050 - 6-axis IMU
  • HMC5883L - 3-axis magnetometer
  • 2Γ— L298N - Dual H-bridge motor drivers
  • TDS Sensor - Water conductivity
  • 12V DC Motors - Propulsion
  • Peristaltic Pump - Water sampling

Software - Backend

  • Python 3.9+ - Raspberry Pi controller
  • Node.js + Express - Backend API server
  • MongoDB - Cloud database
  • SQLite - Local offline database
  • MQTT (Mosquitto) - Real-time communication
  • FastAPI - AI model inference API

Software - Frontend

  • Next.js 14 - React framework
  • TypeScript - Type-safe development
  • Tailwind CSS - Styling
  • Leaflet - Interactive maps
  • Chart.js - Data visualization
  • Socket.io - Real-time updates

AI/ML Models

  • YOLOv8n (Ultralytics) - Object detection
  • CatBoost - Gradient boosting for regression
  • LightGBM - Alternative ML model
  • SHAP - Model explainability
  • scikit-learn - Preprocessing & metrics
  • OpenCV - Image processing

Development Tools

  • Arduino IDE - ESP32 firmware
  • VS Code - Development environment
  • Git - Version control
  • Docker (optional) - Containerization

Communication Protocols

  • MQTT - Pub/Sub messaging
  • WebSocket - Real-time web updates
  • IΒ²C - Sensor communication
  • UART/Serial - RPi ↔ ESP32 communication
  • REST API - HTTP endpoints

πŸ“¦ Installation & Setup

Prerequisites

  • Raspberry Pi 4 (4GB+ RAM) with Raspberry Pi OS
  • ESP32 development board
  • Node.js 18+ (for backend server)
  • Python 3.9+ (for Raspberry Pi)
  • Arduino IDE (for ESP32 firmware)
  • MongoDB database (local or cloud)
  • MQTT broker (Mosquitto or cloud service)

Step 1: Hardware Assembly

Refer to detailed wiring guides:

Step 2: Setup Raspberry Pi

# SSH into your Raspberry Pi
ssh pi@raspberrypi.local

# Update system
sudo apt update && sudo apt upgrade -y

# Enable I2C, Serial, and Camera
sudo raspi-config
# Interface Options β†’ Enable I2C, Serial, Camera
# Reboot after changes

# Clone repository
git clone https://github.com/AhqafCoder/GANDHARVAS_SIH25204.git
cd GANDHARVAS_SIH25204/raspberry-pi

# Install Python dependencies
pip3 install -r requirements.txt

# Configure settings
cp config.yaml.example config.yaml
nano config.yaml  # Edit with your settings

Step 3: Setup ESP32 Firmware

# On your development PC (Windows/Mac/Linux)

# 1. Install Arduino IDE from https://www.arduino.cc/

# 2. Add ESP32 board support:
#    File β†’ Preferences β†’ Additional Board Manager URLs:
#    https://dl.espressif.com/dl/package_esp32_index.json

# 3. Install ESP32 boards:
#    Tools β†’ Board β†’ Boards Manager β†’ Search "ESP32" β†’ Install

# 4. Open firmware
#    File β†’ Open β†’ firmware/esp32_motor_controller/esp32_motor_controller.ino

# 5. Configure
#    Tools β†’ Board β†’ ESP32 Dev Module
#    Tools β†’ Port β†’ (Select your COM port)

# 6. Upload
#    Click Upload button (β†’)

Step 4: Setup Backend Server

# On server machine or cloud instance

# Clone repository
git clone https://github.com/AhqafCoder/GANDHARVAS_SIH25204.git
cd GANDHARVAS_SIH25204/server

# Install dependencies
npm install

# Setup environment variables (see below)
cp .env.example .env
nano .env  # Configure your settings

# Start server
npm start

# Or with PM2 for production
npm install -g pm2
pm2 start index.js --name boat-server

Step 5: Setup Frontend Dashboard

# On your development machine

cd GANDHARVAS_SIH25204/client

# Install dependencies
npm install

# Configure API endpoint
# Edit .env.local
echo "NEXT_PUBLIC_API_URL=http://your-server:3000" > .env.local
echo "NEXT_PUBLIC_WS_URL=ws://your-server:3000" >> .env.local

# Development mode
npm run dev

# Production build
npm run build
npm start

Step 6: Setup AI Models

# Setup Macro AI (YOLOv8)
cd GANDHARVAS_SIH25204/ai\ macro/dataset-pipeline

# Install dependencies
pip install -r requirements.txt

# Download/train model
python train_70epochs.py

# Setup Micro AI (CatBoost)
cd ../../ai\ micro

# Install dependencies
pip install -r requirements.txt

# Train models
python train_improved.py

# Start inference API
cd api
uvicorn main:app --host 0.0.0.0 --port 8000

πŸ” Environment Variables

Backend Server (.env)

# Server Configuration
PORT=3000
NODE_ENV=production

# MongoDB
MONGODB_URI=mongodb://localhost:27017/boat_monitoring
# Or MongoDB Atlas:
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/boat_monitoring

# MQTT Broker
MQTT_BROKER_URL=mqtt://localhost:1883
# Or cloud broker:
# MQTT_BROKER_URL=mqtts://broker.hivemq.com:8883
MQTT_USERNAME=boat_user
MQTT_PASSWORD=your_secure_password
MQTT_CLIENT_ID=backend_server

# JWT Authentication (Optional)
JWT_SECRET=your_jwt_secret_key_here

# File Upload
UPLOAD_DIR=./uploads
MAX_FILE_SIZE=10485760  # 10MB

# API Keys (if using external services)
WEATHER_API_KEY=your_weather_api_key
MAPS_API_KEY=your_maps_api_key

Raspberry Pi (config.yaml)

# Boat Configuration
boat_id: "BOAT_001"

# Server Connection
mqtt:
  broker: "mqtt://your-server.com:1883"
  username: "boat_user"
  password: "your_password"
  topics:
    status: "boat/BOAT_001/status"
    data: "boat/BOAT_001/data"
    commands: "boat/BOAT_001/commands"

# Hardware Settings
hardware:
  esp32_port: "/dev/ttyUSB0"
  esp32_baud: 115200
  gps_port: "/dev/serial0"
  gps_baud: 9600
  camera_resolution: [1920, 1080]

# Sampling Configuration
sampling:
  interval_meters: 10  # Sample every 10 meters
  spectral_integration_time: 50  # ms
  pump_duration: 5  # seconds

# AI Models
ai:
  yolo_model: "models/yolov8n_plastic_algae.pt"
  chlorophyll_model: "http://your-server:8000/predict/chlorophyll"
  confidence_threshold: 0.6

# Database
database:
  local_path: "data/boat_data.db"
  sync_interval: 300  # seconds (5 minutes)

Frontend (.env.local)

NEXT_PUBLIC_API_URL=http://localhost:3000
NEXT_PUBLIC_WS_URL=ws://localhost:3000
NEXT_PUBLIC_MQTT_BROKER=ws://localhost:9001
NEXT_PUBLIC_MAP_TILE_URL=https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png

πŸš€ Usage Guide

Starting the System

  1. Start Backend Server

    cd server
    npm start
  2. Start Raspberry Pi Controller

    cd raspberry-pi
    python3 boat_controller.py
  3. Start Frontend Dashboard

    cd client
    npm run dev
  4. Access Dashboard

    • Open browser: http://localhost:3000

Creating a Mission

  1. Navigate to Mission Planner tab
  2. Click on map to add waypoints
  3. Set mission parameters:
    • Start coordinates
    • Destination coordinates
    • Sampling interval (meters)
    • Waypoint sequence
  4. Click Save Mission
  5. Deploy boat and click Start Mission

Monitoring Real-Time Data

  • Map View: See boat position, track history, waypoints
  • Dashboard: Live sensor readings, water quality metrics
  • Charts: Time-series graphs of chlorophyll, TDS, etc.
  • Alerts: Notifications for anomalies (high chlorophyll, plastic detected)

Manual Control

Use the Command Panel to:

  • FORWARD - Move forward
  • BACKWARD - Move backward
  • LEFT - Turn left
  • RIGHT - Turn right
  • STOP - Stop all motors
  • PUMP_ON - Start water sampling
  • PUMP_OFF - Stop pump
  • RTH - Return to home

Data Analysis

  1. Navigate to Data Explorer
  2. Filter by date range, location, or parameters
  3. Export data as CSV/JSON
  4. View AI predictions and confidence scores
  5. Download captured images

πŸ“Έ Screenshots

Dashboard Overview

Dashboard

Mission Planning

Mission Planner

Water Quality Charts

Charts

Plastic Detection

Plastic Detection

Boat Hardware

Hardware

Note: Replace placeholder images with actual screenshots from your deployed system.


πŸ‘₯ Team

Team Gandharvas - Smart India Hackathon 2025
Institute: Invertis University

Name Role
Sarthak Maurya R&D Lead & Hardware Lead
Aadya Saraswat R&D and Designing Lead
Ahqaf Ali Hardware & Backend Lead
Vivek Vishwakarma AI/ML Lead
Lal Shivam Singh UI/UX Lead
Trisha Bhardwaj Documentation Lead

πŸ“š Documentation

For detailed documentation, refer to:


πŸ”§ Troubleshooting

Boat not connecting to server

  • Check internet connectivity
  • Verify MQTT broker URL and credentials
  • Check firewall settings on server

Sensors not reading

  • Verify I2C connections: i2cdetect -y 1
  • Check power supply to sensors
  • Ensure proper pull-up resistors on I2C lines

Motors not responding

  • Test ESP32 serial communication: screen /dev/ttyUSB0 115200
  • Check motor driver connections
  • Verify battery voltage (should be 11-12.6V)

GPS not getting fix

  • Move to open area (away from buildings)
  • Wait 2-3 minutes for satellite lock
  • Check GPS antenna connection

AI models not working

  • Ensure model files are in correct paths
  • Check FastAPI server is running
  • Verify network connectivity to inference API

🀝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a 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 developed for Smart India Hackathon 2025.


πŸ™ Acknowledgments

  • Smart India Hackathon for the opportunity
  • Invertis University for support and resources
  • Ultralytics for YOLOv8 framework
  • CatBoost team for ML library
  • OpenStreetMap for map tiles

πŸ“ž Contact

For questions or support:


Made with ❀️ by Team Gandharvas

⭐ Star this repository if you find it helpful!

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages