A comprehensive IoT-enabled hospital bed occupancy management system with real-time hardware integration, ML-powered predictions, and intelligent dashboard monitoring for efficient healthcare resource management.
- ESP8266-based intelligent bed monitoring
- Temperature and weight-based occupancy detection
- RFID staff verification system
- Real-time status indication via LCD and LED
- Automated cleaning status management
- Modern React-based web interface
- Real-time bed status monitoring
- Staff authentication and access control
- Comprehensive bed management features
-
π§ Hardware Integration
- ESP8266 + MLX90614 temperature sensor + FSR pressure sensor
- Real-time occupancy detection with body heat and weight sensing
- 12-second connection timeout with automatic offline detection
- Hardware status logging (online/offline transitions)
- Temperature and pressure data display on dashboard
-
π Smart Dashboard
- Real-time bed status with color-coded indicators
- Ward-wise organization (ICU, Maternity, General)
- Advanced filtering system (Available, Occupied, Unoccupied, Cleaning, By Ward)
- Supervisor override system with persistent state management
- Patient assignment with 6-digit ID validation and 30-minute timer
- Responsive design with collapsible ward sections
- Status summary cards with counts by type
-
π Analytics & History
- Recent changes display (limited to 5 entries with "View All" option)
- Full history page with statistics and comprehensive logging
- Hardware connection status tracking in history
- ML-powered hourly patient predictions (26 expected patients)
- Real-time status change notifications
-
π Security & Authentication
- Firebase Authentication with persistent login
- Supervisor override with dual authentication (Employee ID + Password)
- Comprehensive audit logging with timestamps and staff IDs
- Secure real-time database with Firebase rules
-
π¨ User Experience
- Modern TailwindCSS styling with consistent color scheme
- Smooth animations and hover effects
- Navbar with Dashboard, Analytics, and Logs navigation
- Auto-scroll to top on page navigation
- Compact sensor data display for space efficiency
- Frontend: React 18 + Vite + TailwindCSS
- Database: Firebase Realtime Database + Authentication
- Hardware: ESP8266 + MLX90614 (Temperature) + FSR (Pressure)
- Backend: Python Flask + scikit-learn (ML Predictions)
- State Management: React Context API + Firebase Listeners
- Deployment: Node.js environment with real-time synchronization
- π’ Unoccupied - Patient assigned but temporarily away from bed
- π΄ Occupied - Patient currently on the bed
- π Occupied (Cleaning) - Patient on bed that requires cleaning
- π‘ Unoccupied (Cleaning) - Empty bed that needs cleaning
- β« Unassigned - Bed available for new patient assignment
- π Hardware Offline - ESP8266 sensor disconnected (Bed 1 only)
- π΄ ICU Ward - Intensive Care Unit beds with hardware integration for Bed 1
- π Maternity Ward - Maternity and obstetrics beds with custom status tracking
- π΅ General Ward - Standard patient care beds with automated cleaning status
- π€ Collaboration Guide - Team workflow and setup
- π οΈ Development Guide - Development workflow and guidelines
- π Deployment Guide - Production deployment instructions
- β‘ Hardware Setup - Hardware assembly and configuration
- Node.js (v18 or higher)
- npm or yarn
- Firebase project with Realtime Database enabled
-
Clone the repository
git clone <your-repo-url> cd bed-occupancy-management
-
Install dependencies
npm install
-
Firebase Setup
- Create a new Firebase project at Firebase Console
- Enable Authentication with Email/Password provider
- Enable Realtime Database in test mode
- Get your Firebase configuration from Project Settings
-
Configure Firebase
- Open
src/firebase/config.js - Replace the placeholder values with your actual Firebase config:
const firebaseConfig = { apiKey: "your-actual-api-key", authDomain: "your-project-id.firebaseapp.com", databaseURL: "https://your-project-id-default-rtdb.firebaseio.com/", projectId: "your-project-id", storageBucket: "your-project-id.appspot.com", messagingSenderId: "your-messaging-sender-id", appId: "your-app-id" };
- Open
-
Start the development server
npm run dev
-
Open your browser Navigate to
http://localhost:5173
src/
βββ components/
β βββ Analytics.jsx # Analytics and predictions page
β βββ BedCard.jsx # Individual bed status card with hardware integration
β βββ Dashboard.jsx # Main dashboard with filtering and ward management
β βββ FullHistory.jsx # Complete history page with statistics
β βββ HistoryTable.jsx # Recent changes table component
β βββ LoginPage.jsx # Authentication page
β βββ Navbar.jsx # Navigation bar with Dashboard/Analytics/Logs
β βββ PredictionBox.jsx # ML prediction display component
βββ contexts/
β βββ AuthContext.jsx # Authentication context with persistent login
βββ firebase/
β βββ bedManager.js # Bed status management and logging functions
β βββ config.js # Firebase configuration
β βββ seedData.js # Sample data seeding utilities
β βββ statusResolver.js # Status resolution and validation
βββ services/
β βββ PredictionService.js # ML prediction API integration
βββ utils/
β βββ bedUtils.js # Bed status utilities and color mappings
β βββ hardwareBed.js # ESP8266 hardware integration and monitoring
β βββ statusMapping.js # Status conversion and mapping utilities
βββ App.jsx # Main app with navigation routing
βββ main.jsx # App entry point
βββ index.css # TailwindCSS imports and custom styles
backend/
βββ app.py # Flask ML prediction server
βββ ml_model.pkl # Trained scikit-learn model
βββ requirements.txt # Python dependencies
hardware/
βββ ESP8266 Code/
β βββ code.cpp # Main ESP8266 firmware with sensor integration
β βββ hardware_only_code.cpp # Hardware-only version
βββ Schematic/
βββ Curalink.fzz # Fritzing schematic file
βββ Curalink_schematic.png # Circuit diagram
{
"beds": {
"bed1": {
"status": "unoccupied",
"lastUpdate": "2025-09-02T14:00:00",
"assignedNurse": "",
"cleaningStaff": ""
},
"bed2": {
"status": "occupied",
"lastUpdate": "2025-09-02T13:30:00",
"assignedNurse": "NURSE45",
"cleaningStaff": ""
}
},
"history": {
"entry1": {
"bedId": "bed1",
"status": "occupied",
"assignedNurse": "NURSE45",
"cleaningStaff": "",
"timestamp": "2025-09-02T14:00:00"
}
}
}- Create an account or sign in using the login page
- Seed sample data by clicking the "Seed Sample Data" button when prompted
- Explore the dashboard to see bed statuses and statistics
- View bed status in color-coded cards organized by ward with real-time updates
- Filter beds using the priority-ordered dropdown: All β Available β Occupied β Unoccupied β Cleaning
- Filter by ward (ICU, Maternity, General) with collapsible sections
- Assign patients with 6-digit ID validation and 30-minute auto-expiration timer
- Monitor hardware - Bed 1 shows live temperature, pressure, and connection status
- View recent changes (last 5) with "View All Changes" button for complete history
- Navigate between Dashboard, Analytics, and Logs using the top navigation
- Real-time monitoring with ESP8266 + MLX90614 temperature + FSR pressure sensors
- Connection status - Shows "π’ Connected" or "π΄ Hardware Not Connected"
- Sensor data display - Temperature (Β°C) and pressure values with detection indicators
- Automatic offline detection - 12-second timeout with "Hardware Offline" status
- Status logging - All hardware connect/disconnect events logged in history
The system includes a secure supervisor override feature for authorized personnel:
Valid Supervisor Credentials:
- Employee ID:
220306or130506 - Password:
admin@123
Features:
- Always-visible supervisor override buttons on every bed
- Employee ID must be exactly 6 digits
- Real-time validation with error messages
- Comprehensive audit logging with Employee ID and timestamp
- Manual bed status changes for emergency situations
All status changes are automatically:
- β Saved to Firebase Realtime Database
- β Logged in the history table
- β Updated across all connected clients in real-time
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run lint- Run ESLint
The app includes a seedData.js file that provides:
- 6 sample beds across 3 wards:
- ICU Ward (Beds 1-2): Bed 1 with hardware integration
- Maternity Ward (Beds 3-4): Standard monitoring
- General Ward (Beds 5-6): Standard monitoring
- Automatic status synchronization for hardware-integrated bed
- Sample history entries with timestamps
- Easy data seeding function for testing
The dashboard uses Firebase Realtime Database listeners to provide:
- Instant updates across all connected clients
- Automatic synchronization of bed status changes
- Live history updates
- Simple email/password authentication
- Persistent login state
- Secure access to dashboard features
For production deployment:
- Configure Firebase Security Rules
- Enable Firebase App Check
- Set up proper CORS policies
- Use environment variables for sensitive config
- Implement proper user roles and permissions
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
-
Firebase connection errors
- Verify your Firebase config is correct
- Check if Realtime Database is enabled
- Ensure authentication is set up
-
Build errors
- Clear node_modules and reinstall
- Check Node.js version compatibility
-
CSS not loading
- Verify TailwindCSS configuration
- Check PostCSS config is correct
If you encounter any issues, please check the console for error messages and ensure all Firebase services are properly configured.