Skip to content

sohelshekhIn/SchoolBell-IOT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”” SchoolBell - Automated School Bell System

Currently deployed and operational at BVB School, Nadiad 🏫

An intelligent IoT-based school bell automation system that combines modern web technology with Raspberry Pi hardware to deliver precise, reliable bell scheduling for educational institutions.

🌟 Live Implementation

This system is actively running at BVB School, Nadiad, successfully automating their daily bell schedule and providing administrative control through a modern web dashboard.

🎯 Project Overview

SchoolBell is a complete IoT solution that automates school bell operations through:

  • Web Dashboard: Modern Next.js interface for schedule management and system control
  • Raspberry Pi Controller: Hardware interface for bell control with offline capability
  • Firebase Integration: Cloud synchronization and real-time data management
  • Multi-level Security: PIN-based authentication system with brute force protection

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Web Dashboard │◄──►│    Firebase     │◄──►│  Raspberry Pi   β”‚
β”‚   (Next.js)     β”‚    β”‚   (Database)    β”‚    β”‚   (Controller)  β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚ β€’ Schedule Mgmt β”‚    β”‚ β€’ Data Storage  β”‚    β”‚ β€’ GPIO Control  β”‚
β”‚ β€’ Manual Controlβ”‚    β”‚ β€’ Command Queue β”‚    β”‚ β€’ Local Storage β”‚
β”‚ β€’ Activity Logs β”‚    β”‚ β€’ Device Status β”‚    β”‚ β€’ Scheduling    β”‚
β”‚ β€’ Settings Panelβ”‚    β”‚ β€’ Sync System   β”‚    β”‚ β€’ Time Sync     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

✨ Key Features

πŸ”” Automated Bell Scheduling

  • Pre-configured school timetables (weekday/Saturday)
  • Period-based scheduling with break management
  • Special day override capability for events/holidays
  • Offline operation with local data persistence

πŸŽ›οΈ Manual Control System

  • Instant bell activation through web interface
  • PIN-protected emergency controls
  • Configurable bell duration (1-10 seconds)
  • Real-time status feedback

πŸ“Š Activity Monitoring

  • Comprehensive logging of all bell activities
  • Real-time system status monitoring
  • Device connectivity tracking
  • Historical activity reports

πŸ”’ Multi-level Security

  • Site PIN (8 digits): Dashboard access control
  • User PIN (8 digits): Manual control and schedule modifications
  • Master PIN (10 digits): System configuration and PIN management
  • Brute force protection with progressive delays

🌐 Cloud Integration

  • Firebase-based data synchronization
  • Remote system monitoring and control
  • Automatic backup and recovery
  • Cross-platform accessibility

πŸ“… Default Schedule Implementation

Monday to Friday

Period 1:    08:15 - 08:55
Period 2:    08:55 - 09:35
Short Break: 09:35 - 09:45
Period 3:    09:45 - 10:25
Period 4:    10:25 - 11:05
Period 5:    11:05 - 11:40
Long Break:  11:40 - 12:00
Period 6:    12:00 - 12:40
Period 7:    12:40 - 13:20
Period 8:    13:20 - 14:00

Saturday

Period 1:    08:15 - 08:55
Period 2:    08:55 - 09:35
Short Break: 09:35 - 09:45
Period 3:    09:45 - 10:25
Period 4:    10:25 - 11:05
Period 5:    11:05 - 11:45

πŸš€ Quick Start Guide

Prerequisites

  • Raspberry Pi (3B+ or newer recommended)
  • Node.js 18+ for dashboard development
  • Python 3.7+ for Pi controller
  • Firebase account
  • GPIO-compatible relay module

1. Dashboard Setup

cd dashboard
npm install

Create .env.local with your Firebase configuration:

NEXT_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
NEXT_PUBLIC_FIREBASE_API_KEY=your-api-key
# Add other Firebase config variables
# Development
npm run dev

# Production build
npm run build

2. Raspberry Pi Installation

Choose your preferred installation method:

Option A: Standard Installation (Recommended)

cd dietpi
sudo ./install.sh

Option B: Pyrebase Version (Lightweight)

cd dietpi
sudo ./install_pyrebase.sh

Option C: Hybrid Node.js Bridge (Advanced)

cd new-dietpi
sudo ./install.sh

3. Firebase Configuration

  1. Create a Firebase project
  2. Download service account key
  3. Place in appropriate directory based on installation method
  4. Update project ID in configuration files
  5. Deploy Firestore security rules

4. Hardware Setup

Connect your bell system to Raspberry Pi GPIO:

  • GPIO 22: Primary relay control
  • GPIO 23: Secondary relay control
  • 3.3V/GND: Relay module power

πŸ“ Project Structure

SchoolBell/
β”œβ”€β”€ dashboard/                 # Next.js Web Dashboard
β”‚   β”œβ”€β”€ app/                  # Next.js 13+ app directory
β”‚   β”‚   β”œβ”€β”€ api/             # API routes
β”‚   β”‚   └── components/      # React components
β”‚   β”œβ”€β”€ lib/                 # Utility libraries
β”‚   β”œβ”€β”€ public/              # Static assets
β”‚   └── firebase.json        # Firebase hosting config
β”‚
β”œβ”€β”€ dietpi/                   # Standard Pi Controller
β”‚   β”œβ”€β”€ main.py              # Primary controller script
β”‚   β”œβ”€β”€ install.sh           # Installation script
β”‚   └── requirements.txt     # Python dependencies
β”‚
β”œβ”€β”€ new-dietpi/              # Hybrid Node.js Bridge Version
β”‚   β”œβ”€β”€ firebase-bridge.js   # Node.js Firebase interface
β”‚   β”œβ”€β”€ main.py              # Python bell controller
β”‚   └── install.sh           # Hybrid installation
β”‚
└── Documentation/
    β”œβ”€β”€ DEPLOYMENT.md         # Detailed deployment guide
    β”œβ”€β”€ QUICK-PI-SETUP.md    # Rapid Pi setup instructions
    └── SOLUTION-SUMMARY.md   # Technical implementation details

πŸ”§ Configuration Options

Environment Variables

Dashboard

PI_BASE_URL=http://192.168.1.100:5000
NEXT_PUBLIC_SITE_PIN=12345678
NEXT_PUBLIC_USER_PIN=87654321
NEXT_PUBLIC_MASTER_PIN=1234567890

Raspberry Pi

# GPIO Configuration
RELAY_PIN_1 = 22
RELAY_PIN_2 = 23

# Bell Settings
DEFAULT_BELL_DURATION = 5  # seconds

# Security
MASTER_PIN = "1234567890"  # Change this!
USER_PIN = "87654321"      # Change this!

πŸ› οΈ API Reference

Dashboard API Endpoints

  • GET /api/pi-status - Check Pi connectivity
  • POST /api/ring-bell - Manual bell activation
  • GET /api/logs - Retrieve activity logs
  • POST /api/sync-schedule - Force schedule synchronization

Pi Controller API

  • GET /api/status - System status and health
  • POST /api/ring - Direct bell control
  • POST /api/update_schedule - Schedule updates
  • GET /api/logs - Local activity logs

πŸ” Monitoring & Troubleshooting

System Health Checks

# Check Pi service status
sudo systemctl status schoolbell

# View real-time logs
tail -f /home/dietpi/schoolbell/bell.log

# Test GPIO functionality
python3 -c "import RPi.GPIO as GPIO; GPIO.setmode(GPIO.BCM); GPIO.setup(22, GPIO.OUT); GPIO.output(22, GPIO.HIGH)"

Common Issues & Solutions

Pi Not Responding

  1. Verify network connectivity
  2. Check service status: sudo systemctl status schoolbell
  3. Review logs for error messages
  4. Confirm Firebase configuration

Bell Hardware Issues

  1. Test relay connections
  2. Verify power supply to electromagnet
  3. Check GPIO pin assignments
  4. Test with manual API calls

Time Synchronization Problems

  1. Enable NTP: sudo systemctl enable ntp
  2. Manual sync: sudo ntpdate -s time.nist.gov
  3. Check internet connectivity
  4. Verify timezone settings

πŸš€ Deployment Strategies

Cloud Hosting Options

  • Vercel (Recommended): Easy deployment with automatic HTTPS
  • Firebase Hosting: Integrated with Firebase backend
  • Netlify: Alternative static site hosting
  • Self-hosted: On-premise deployment option

Production Considerations

  • Use environment variables for sensitive configuration
  • Enable Firebase App Check for additional security
  • Set up monitoring and alerting systems
  • Configure automated backup procedures
  • Implement SSL/TLS certificates

πŸ”’ Security Best Practices

  • Change Default PINs: Update all authentication codes before deployment
  • Network Security: Use VPN for remote access when possible
  • Regular Updates: Keep all dependencies and system packages current
  • Access Logging: Monitor and review all system access attempts
  • Backup Strategy: Regular data backups and recovery testing

🀝 Contributing

This project is designed for educational institutions. Contributions welcome for:

  • Additional schedule templates
  • Enhanced security features
  • Mobile application development
  • Integration with school management systems

πŸ“„ License

Private educational use license. Contact for commercial licensing options.

πŸŽ“ Educational Impact

Currently serving BVB School, Nadiad with:

  • βœ… Automated daily bell scheduling
  • βœ… Reduced manual intervention requirements
  • βœ… Improved schedule adherence
  • βœ… Enhanced administrative control
  • βœ… Real-time system monitoring capabilities

Built with ❀️ by Sohel

Making school operations smarter πŸ””

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published