This project is an automated lighting system based on IoT technology, designed for smart cities and home automation. The system uses light sensors (LDR) and motion sensors (PIR) to intelligently control lighting based on environmental conditions. The decision-making process takes place in the cloud, ensuring efficient energy management.
/Smart-Lighting-IoT
│── /ArduinoMkrWan # LoRaWAN-based implementation (The Things Network)
│ │── mkrwan.ino # Firmware for LoRaWAN IoT device
│ │── payloadformatterdownlink.txt # Downlink payload formatter for TTN
│ │── mqtt.py # MQTT-based communication script for TTN
| │── payloadformatterUplink.txt # uplink payload formatter for TTN
| │── index.html # Web interface for remote control
│
│── /esp32 # WiFi-based implementation (ThingSpeak)
│ │── esp32.ino # Firmware for ESP32 IoT device (WiFi communication)
│
│── Report.pdf
│── README.md # Documentation and instructions
- Automatic lighting control based on real-time light intensity and motion detection.
- LoRaWAN implementation using The Things Network (TTN) for low-power, long-range communication.
- WiFi implementation using ThingSpeak for cloud integration and remote control.
- Web Interface for users to manually control and monitor the lighting system.
- MQTT communication for real-time data exchange between IoT devices and cloud platforms.
- ESP32 microcontroller (for WiFi-based system)
- Arduino MKR WAN 1300 (for LoRaWAN-based system)
- LDR (Light Dependent Resistor) sensor (for light intensity detection)
- PIR Motion Sensor (for movement detection)
- LED or Relay Module (for controlling the light)
- Resistors, jumper wires, and a breadboard
- Power supply (USB or battery)
- Arduino IDE (for programming ESP32 and MKR WAN 1300)
- The Things Network (TTN) account (for LoRaWAN setup)
- ThingSpeak account (for WiFi-based cloud storage)
- Python 3 (for running the MQTT broker script)
- Live Server (for the web server via VScode)
- Paho MQTT (for handling MQTT messages)
- Sensors (LDR & PIR) collect data → Light intensity (L) & Movement (P).
- Data is transmitted to the cloud:
- LoRaWAN implementation: Sent to TTN via mkrwan.ino.
- WiFi implementation: Sent to ThingSpeak via esp32.ino.
- Cloud processes the data and makes a decision (ON/OFF).
- The decision is sent back to the IoT device:
- TTN downlink message (LoRaWAN).
- ThingSpeak API request (WiFi).
- The IoT device activates or deactivates the light accordingly.
- Users can manually control the system via the web interface (index.html).
- Register a TTN account.
- Create an IoT application and add a device (MKR WAN 1300).
- Configure uplink & downlink messages.
- Add the payload formatter (
payloadformatterdownlink.txt).
- Open
mkrwan.inoin Arduino IDE. - Install LoRaWAN libraries.
- Compile and upload the firmware to the MKR WAN 1300.
- Install Paho MQTT:
pip install paho-mqtt - Run the MQTT script:
python mqtt.py
- Register a ThingSpeak account.
- Create a new channel for light & motion data.
- Note down the API keys for sending/receiving data.
- Open
esp32.inoin Arduino IDE. - Install ESP32 board support.
- Add WiFi credentials and ThingSpeak API keys.
- Compile and upload the firmware to the ESP32.
- Open
index.htmlin a web browser. - Control the lighting system remotely.
The web interface allows users to:
- Turn lights ON/OFF manually.
- Enable detection mode (automatic control via sensors).
- Set RGB colors (if LED supports RGB control).
- View real-time sensor data.
To use the interface:
- Start the Live Server (
mqtt.pymust be running). - Open
index.htmlin your browser. - Click the buttons to send commands.