Skip to content

TechSpora/IoT_Smart_Home_System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

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

Repository files navigation

IoT Smart Home System

A comprehensive IoT solution for smart home automation with mobile app control, voice integration, energy monitoring, and security system.

Features

πŸ“± Device Control

  • Control lights, thermostats, and other smart devices
  • Real-time device status monitoring
  • Brightness and temperature control
  • Individual device management

🎀 Voice Integration

  • Voice commands for device control
  • Text-to-speech feedback
  • Support for natural language commands
  • Voice-activated device switching

⚑ Energy Monitoring

  • Real-time power consumption tracking
  • Energy usage statistics
  • Cost calculation
  • Hourly and daily consumption charts
  • Peak power detection

πŸ”’ Security System

  • Door/window sensors
  • Motion detection
  • Alarm system with notifications
  • Arming/disarming controls
  • Security event logging

Technologies

  • React Native - Mobile application framework
  • Arduino - IoT device programming
  • MQTT - Message queuing telemetry transport
  • AWS IoT - Cloud IoT platform integration

Project Structure

IoT Smart Home System/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ screens/           # React Native screens
β”‚   β”‚   β”œβ”€β”€ HomeScreen.js
β”‚   β”‚   β”œβ”€β”€ DevicesScreen.js
β”‚   β”‚   β”œβ”€β”€ EnergyScreen.js
β”‚   β”‚   β”œβ”€β”€ SecurityScreen.js
β”‚   β”‚   └── VoiceScreen.js
β”‚   β”œβ”€β”€ services/          # Business logic services
β”‚   β”‚   β”œβ”€β”€ mqttService.js
β”‚   β”‚   β”œβ”€β”€ awsIoTService.js
β”‚   β”‚   β”œβ”€β”€ deviceService.js
β”‚   β”‚   β”œβ”€β”€ energyService.js
β”‚   β”‚   β”œβ”€β”€ securityService.js
β”‚   β”‚   └── voiceService.js
β”‚   └── theme.js           # App theme configuration
β”œβ”€β”€ arduino/               # Arduino device code
β”‚   β”œβ”€β”€ smart_light/
β”‚   β”œβ”€β”€ energy_monitor/
β”‚   β”œβ”€β”€ security_sensor/
β”‚   └── thermostat/
β”œβ”€β”€ config/                # Configuration files
└── README.md

Installation

Prerequisites

  • Node.js 14+ and npm
  • React Native development environment
  • Arduino IDE
  • ESP8266 or ESP32 development board
  • MQTT broker (local or cloud)

Mobile App Setup

  1. Install dependencies:

    npm install
  2. Configure connection:

    • Copy config/config.example.js to config/config.js
    • Update MQTT broker URL and AWS IoT credentials
  3. Run the app:

    # For Expo
    npm start
    
    # For iOS
    npm run ios
    
    # For Android
    npm run android

Arduino Setup

  1. Install Arduino IDE:

  2. Install ESP8266/ESP32 Board Support:

    • File β†’ Preferences β†’ Additional Board Manager URLs
    • Add ESP8266/ESP32 board URLs (see arduino/libraries.md)
  3. Install Required Libraries:

    • PubSubClient (MQTT)
    • ArduinoJson (JSON parsing)
    • DHT sensor library (for thermostat)
  4. Configure and Upload:

    • Open the appropriate .ino file
    • Update WiFi credentials and MQTT broker settings
    • Select your board (ESP8266 or ESP32)
    • Upload to device

Configuration

MQTT Broker Setup

Local MQTT Broker (Mosquitto):

  1. Install Mosquitto:

    # Windows (using Chocolatey)
    choco install mosquitto
    
    # macOS
    brew install mosquitto
    
    # Linux
    sudo apt-get install mosquitto mosquitto-clients
  2. Start Mosquitto:

    # Default port 1883
    mosquitto -p 1883
    
    # With WebSocket support (port 8083)
    mosquitto -p 1883 -c /path/to/mosquitto.conf
  3. Mosquitto Configuration (for WebSocket):

    listener 1883
    protocol mqtt
    
    listener 8083
    protocol websockets
    

Cloud MQTT Broker:

AWS IoT Setup

  1. Create AWS IoT Thing:

    • Go to AWS IoT Console
    • Create a new Thing
    • Download certificates
  2. Configure Policy:

    • Create IoT policy with permissions:
      {
        "Effect": "Allow",
        "Action": ["iot:Connect", "iot:Publish", "iot:Subscribe", "iot:Receive"],
        "Resource": "*"
      }
      
  3. Update Configuration:

    • Add endpoint to config/config.js
    • Configure credentials (Cognito/IAM roles recommended)

Usage

Device Control

  1. Navigate to Devices tab
  2. View all connected devices
  3. Toggle devices on/off
  4. Adjust brightness (for lights) or temperature (for thermostat)

Energy Monitoring

  1. Navigate to Energy tab
  2. View real-time power consumption
  3. Check hourly and daily consumption charts
  4. Monitor energy costs

Security System

  1. Navigate to Security tab
  2. Arm/disarm security system
  3. View sensor status
  4. Check recent security events

Voice Control

  1. Navigate to Voice tab
  2. Tap "Start Listening"
  3. Speak commands:
    • "Turn on [device name]"
    • "Turn off [device name]"
    • "Brightness 50 [device name]"
    • "Temperature 22 [device name]"

MQTT Topics

Device Control:

  • device/{deviceId}/control - Send commands to devices
  • device/{deviceId}/status - Receive device status updates

Energy Monitoring:

  • energy/monitoring - Energy consumption data

Security:

  • security/alarm - Security alarms
  • security/sensor - Sensor status updates
  • security/control - Security system control
  • security/motion - Motion detection events

Hardware Connections

Smart Light:

  • LED connected to GPIO pin with PWM support
  • Optional: LDR (Light Dependent Resistor) for ambient light sensing

Energy Monitor:

  • ACS712 Current Sensor (5A, 20A, or 30A variant)
  • Optional: Voltage divider for voltage measurement

Security Sensor:

  • Magnetic Reed Switch (for door/window)
  • OR PIR Motion Sensor (for motion detection)
  • Optional: Buzzer for local alarm

Thermostat:

  • DHT22 or DS18B20 temperature sensor
  • Optional: Relay module for HVAC control

Troubleshooting

Mobile App Issues:

  • Connection failed: Check MQTT broker URL and network connectivity
  • Devices not updating: Verify MQTT subscriptions and message format
  • Voice not working: Ensure microphone permissions are granted

Arduino Issues:

  • WiFi not connecting: Verify SSID and password
  • MQTT not connecting: Check broker IP address and port
  • Sensor readings incorrect: Verify pin connections and sensor calibration

Development

Adding New Devices:

  1. Create new Arduino sketch in arduino/ directory
  2. Implement MQTT communication following existing patterns
  3. Add device type to deviceService.js
  4. Create UI components in appropriate screen

Customizing Features:

  • Modify services in src/services/ for business logic changes
  • Update screens in src/screens/ for UI changes
  • Adjust configuration in config/config.js

License

This project is provided as-is for educational and development purposes.

Support

For issues and questions:

  • Check Arduino libraries installation
  • Verify MQTT broker connectivity
  • Review configuration files
  • Check device logs and serial output

Contributing

Contributions are welcome! Please ensure:

  • Code follows existing patterns
  • Arduino code includes proper error handling
  • Mobile app code is properly tested
  • Documentation is updated

Note: This is a comprehensive IoT smart home system. Ensure all devices are properly configured and secured before deployment in production environments.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published