A comprehensive IoT solution for monitoring and managing smart refrigerators with real-time sensor data collection, web dashboard, and Telegram bot integration.
- Real-time Monitoring: Continuous tracking of temperature, humidity, door status, and power consumption
- Multi-sensor Support: Internal/external temperature and humidity sensors
- Door Status Detection: Monitor fridge door open/close events with automatic alerts
- Power Consumption Tracking: Monitor energy usage patterns
- Alarm System: Visual and audible alerts for temperature anomalies and extended door opening
- Predictive Analytics: ML-powered user behavior prediction using Random Forest algorithm
- Telegram Bot Integration: Real-time notifications and remote monitoring via Telegram
- Web Dashboard: Comprehensive web interface for data visualization and management
- Multi-user Support: Role-based access control for operators and customers
- Historical Data: Complete sensor data history with graphical representation
-
Temperature Alarms: Automatic alerts when temperature exceeds safe ranges
-
Door Alerts: Buzzer activation after 10 seconds of door being open
-
Real-time Notifications: Instant Telegram notifications for out-of-range values
-
LED Indicators: Visual feedback system on Arduino hardware
smart-fridge-system/
โโโ bot/
โ โโโ bot.py # Telegram bot implementation
โโโ codes/
โ โโโ Arduino/
โ โ โโโ all_sensors/
โ โ โโโ all_sensors.ino # Arduino sensor code
โ โโโ bridge_Serial_HTTP.py # Serial to HTTP bridge
โโโ config/
โ โโโ main/
โ โโโ urls.py # Django URL routing
โ โโโ views.py # Django views and API endpoints
โ โโโ models.py # Database models (implied)
โโโ README.md # This file
- Arduino UNO (or compatible microcontroller)
- 2x DHT11 sensors (internal and external temperature/humidity)
- Push button (door status sensor)
- Buzzer (alarm system)
- LED (status indicator)
- Potentiometer (power consumption simulation)
- Resistors and connecting wires
- DHT11 Internal: Pin 5
- DHT11 External: Pin 6
- Door Button: Pin 2
- Buzzer: Pin 9
- LED: Pin 10
- Potentiometer: Analog Pin A0
- Python 3.8+
- Django 4.x
- pandas
- scikit-learn
- joblib
- requests
- pyserial
- SimpleDHT (for DHT11 sensors)
- python-telegram-bot
- Connect all sensors to Arduino according to the pin configuration
- Upload
codes/Arduino/all_sensors/all_sensors.inoto your Arduino - Connect Arduino to your computer via USB
# Clone the repository
git clone <repository-url>
cd smart-fridge-system
# Install Python dependencies
pip install django pandas scikit-learn joblib requests pyserial python-telegram-bot
# Set up Django
cd config
python manage.py migrate
python manage.py collectstatic
python manage.py createsuperuser
# Start Django server
python manage.py runserverCreate a config.ini file in the bridge directory:
[DJANGO]
Url = http://127.0.0.1:8000/api/
X-AIO-Key = your-api-key
[Serial]
UseDescription = true
PortDescription = arduino
PortName = COM3
[TELEGRAM]
Url = your-telegram-bot-url- Create a new bot using @BotFather
- Get your bot token
- Update
BOT_TOKENin bothbot/bot.pyandconfig/main/views.py - Start the bot:
cd bot
python bot.pycd codes
python bridge_Serial_HTTP.py- Navigate to
http://127.0.0.1:8000 - Register/login to access the dashboard
- Register a new fridge (operators) or add existing fridge (customers)
- View real-time data, charts, and alarm history
/start <fridge_id>- Subscribe to fridge notifications/status <fridge_id>- Get current sensor readings/behaviour <fridge_id>- Get behavior prediction/help- Show available commands/stop- Unsubscribe from notifications
The bot supports natural language commands using XLM-RoBERTa for intent classification:
- "How is my fridge doing?" โ Status command
- "Stop sending me alerts" โ Stop command
- "I need help" โ Help command
- "How am I behaving?" โ Behaviour prediction
The system uses a Random Forest classifier to predict user behavior based on:
- External Temperature: Environmental conditions
- Internal Temperature Variation: Temperature changes during door opening
- Door Open Time: Duration the fridge door remains open
- 0 (Good): "You are acting on the right track"
- 2 (Medium): "You are doing well, but you can do better"
- 1 (Bad): "You are acting irresponsibly"
POST /data/- Receive sensor data from bridgeGET /data/alarm/<pk>/- Check alarm status for bridge
POST /api/store_chat_id/- Register Telegram userGET /api/get_least_recent_data/- Get latest sensor dataGET /api/data/predict/<pk>/- Get behavior prediction
GET /chart-data/<pk>/- Get chart data for visualizationGET /alarmshistory/<pk>/- Get alarm history
ACCEPTABLE_RANGES = {
'int_temp': (0, 10), # ยฐC
'ext_temp': (0, 35), # ยฐC
'int_hum': (20, 70), # %
'power_consumption': (0, 1000), # W
}- Data transmission interval: 5 seconds
- Temperature reading interval: 2 seconds
- Door open alarm threshold: 10 seconds
- Arduino ID: Configurable unique identifier
- User Authentication: Django's built-in authentication system
- Role-based Access: Separate permissions for operators and customers
- API Authorization: X-AIO-Key header validation
- Fridge Association: Secret number verification for fridge registration
- Telegram User Verification: Chat ID and fridge ID validation
- Temperature Exceeding Limits: When internal temperature > 5ยฐC and door closed
- Door Left Open: Visual and audible alerts after 10 seconds
- Out-of-Range Values: Telegram notifications for any sensor reading outside acceptable ranges
- System Status: Real-time LED feedback on Arduino
- Real-time Charts: Temperature, humidity, and power consumption graphs
- Historical Trends: 10-point moving data visualization
- Alarm History: Complete log of all triggered alarms
Arduino not detected:
- Check USB connection and drivers
- Verify correct port in
config.ini - Ensure Arduino IDE can communicate with device
Serial communication errors:
- Verify baud rate (9600) matches in all components
- Check for interference or loose connections
- Monitor serial output for data format consistency
Django server errors:
- Verify all dependencies are installed
- Check database migrations are up to date
- Ensure correct Django settings
Telegram bot not responding:
- Verify bot token is correct
- Check internet connectivity
- Ensure bot is started and running
Missing sensor data:
- Check sensor wiring and power supply
- Verify DHT11 sensors are functional
- Monitor Arduino serial output for sensor readings
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Development Team - Initial work and system architecture
- Contributors - Various improvements and bug fixes
- Arduino community for sensor libraries
- Django framework for robust web backend
- Telegram Bot API for seamless messaging integration
- Hugging Face for NLP model hosting
- scikit-learn for machine learning capabilities
Note: This system is designed for educational and demonstration purposes. For production use, consider additional security measures, error handling, and scalability improvements.