A comprehensive IoT solution for intelligent room environment monitoring and automated control, featuring sensor data collection, edge computing, cloud integration, and real-time notifications.
Real-time monitoring dashboard showing sensor data and actuator controls
The system follows a three-tier architecture:
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ EDGE LAYER โ โ CLOUD LAYER โ โ DASHBOARD โ
โ โ โ โ โ โ
โ Arduino Sensors โโโโโบโ Edge Computing โโโโโบโ ThingsBoard โ
โ Arduino Control โ โ Local Database โ โ Weather API โ
โ โ โ MQTT Broker โ โ Discord Alerts โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
- Microcontroller: Arduino Uno/Nano
- Display: OLED SSD1306 (128x64)
- Actuators:
- LED (Pin 3) - Lighting control
- Fan Motor (Pin 4) - Ventilation
- Servo Motor (Pin 9) - Door/window automation
- Libraries: U8x8lib, Servo
- Microcontroller: Arduino Uno/Nano
- Sensors:
- DHT22 (Pin 7) - Temperature and humidity
- Photoresistor (Pin A0) - Light intensity
- Sound sensor (Pin 6) - Noise detection
- Indicator: Message LED (Pin 2)
- Libraries: DHT
pip install serial pymysql paho-mqtt requests schedule- U8x8lib (OLED display)
- Servo (servo motor control)
- DHT (temperature/humidity sensor)
- Connect sensors and actuators according to pin definitions in the Arduino code
- Upload
Inside_Arduino.inoto the indoor Arduino - Upload
Outside_Arduino.inoto the outdoor Arduino - Connect both Arduinos to the edge computing device via USB
-- Create databases
CREATE DATABASE sensorslog;
CREATE DATABASE actuatorslog;
-- Tables are created automatically by the Python scriptsUpdate configuration variables in the Python files:
MQTT_BROKER = "your_mqtt_broker_ip" # Update in all Python filesDISCORD_WEBHOOK_URL = "your_discord_webhook_url"OPENWEATHER_API_KEY = "your_openweather_api_key"
LOCATION = "your_city,country_code"THINGSBOARD_TOKEN = "your_device_token"# Terminal 1 - Outside edge processing
python outside_edge.py
# Terminal 2 - Inside edge processing
python inside_edge.py
# Terminal 3 - Cloud server
python cloud_server.py- Smart Lighting: LED turns on automatically when ambient light is low
- Ventilation Control: Fan activates when temperature exceeds threshold
- Access Control: Door/window opens based on environmental conditions
- Noise Monitoring: System responds to sound levels for security
- Automatic Mode: System responds to sensor inputs automatically
- Manual Mode: Remote control via ThingsBoard dashboard
- Threshold Adjustment: Dynamic temperature thresholds based on weather
- Real-time Logging: Sensor and actuator data stored in MySQL
- MQTT Communication: Efficient data transmission between components
- Daily Reports: Automated report generation and Discord notifications
- Weather Integration: OpenWeatherMap API for weather-based decisions
- ThingsBoard Dashboard: Real-time monitoring and control
- Discord Notifications: Instant alerts for system events
Real-time sensor monitoring and actuator control interface
Automated alerts and daily reports
Arduino sensors and actuators in operation
edge/outside/data # Sensor data from outdoor unit
edge/outside/status # Acknowledgment messages
edge/inside/data # Actuator status from indoor unit
cloud/control/mode # System mode control
cloud/control/led # LED control
cloud/control/fan # Fan control
cloud/control/door # Door control
cloud/suggestion # Weather-based suggestions
v1/devices/me/telemetry # Data publishing
v1/devices/me/rpc/request/+ # Remote control commands
- Access your ThingsBoard instance
- Monitor real-time sensor data
- Control actuators remotely
- View historical data and analytics
- Receive alerts for threshold breaches
- Get daily reports
- Monitor system mode changes
- Track actuator state changes
-- View recent sensor data
SELECT * FROM sensorslog.logs ORDER BY time DESC LIMIT 10;
-- View actuator activity
SELECT * FROM actuatorslog.logs ORDER BY time DESC LIMIT 10;Arduino Not Detected
# Check USB connection
ls /dev/ttyACM*
ls /dev/ttyUSB*
# Update serial port in Python files
arduino = serial.Serial('/dev/ttyACM0', 9600, timeout=1)MQTT Connection Failed
- Verify broker IP address and port
- Check network connectivity
- Ensure MQTT broker is running
Database Connection Error
- Verify MySQL credentials
- Check if databases exist
- Ensure MySQL service is running
Weather API Issues
- Verify API key is valid
- Check location format
- Monitor API rate limits
Enable debug output by adding print statements or using Python logging:
import logging
logging.basicConfig(level=logging.DEBUG)- Update Interval: 3 seconds for sensor readings
- MQTT Publishing: 10 seconds for telemetry
- Database Logging: Real-time for all events
- Weather Updates: 2 minutes interval
- Report Generation: Daily at 23:59
- Temperature Range: -40ยฐC to 80ยฐC (DHT22)
- Light Range: 0-6000 lux (calculated)
- Sound Detection: Digital threshold-based
- Servo Range: 0ยฐ to 90ยฐ (door control)
