Experiment 8 Iot
Experiment 8 Iot
Aim
To develop a proximity-based smart home automation system using an ESP32 microcontroller, a PIR
sensor, and a web server. This system enables remote control of devices like lights and buzzers via a
responsive HTML-based interface hosted on the ESP32.
Apparatus Required
1. ESP32 Microcontroller Board
4. Buzzer
6. Breadboard
8. Jumper Wires
Theory
The ESP32 is a powerful IoT-enabled microcontroller with built-in Wi-Fi and Bluetooth capabilities. Its
dual-core processor makes it ideal for real-time applications like smart home automation.
1. Host a web server that provides an interactive HTML-based interface for device control.
2. Interface with a PIR sensor to detect motion, triggering actions like turning on lights or
activating a buzzer.
3. Manage connected devices through GPIO pins, controlled by HTTP requests generated from
user interactions on the web interface.
The web interface allows users to control devices wirelessly, making this a cost-effective solution for
scalable smart home systems.
void setup()
{ Serial.begin(115200);
client.println("</body></html>");
4. Optimized Web Server Code: Utilized non-blocking functions to ensure smooth performance
and quick response times.
Connection Diagram
SOURCE CODE:
Procedure
1. Hardware Setup:
o Connect the PIR sensor’s output pin to a GPIO pin (e.g., D12) on the ESP32.
o Connect the LED to another GPIO pin (e.g., D26) with a 220-ohm resistor.
2. Code Development:
o Design a responsive HTML page with buttons to control the LED and buzzer.
o Add logic to read PIR sensor input and trigger actions automatically.
o Implement real-time updates using non-blocking code (e.g., millis() instead of
delay()).
3. Upload Code:
o Open the Arduino IDE, select the ESP32 board, and upload the sketch via USB cable.
o Connect your device to the ESP32’s Wi-Fi network and enter the IP address in a
browser.
o Verify that the PIR sensor detects motion and triggers the devices as programmed.
Observations
1. The ESP32 successfully hosted a web server accessible on any device connected to the same
Wi-Fi network.
2. HTML buttons effectively controlled the LED and buzzer with minimal delay.
3. The PIR sensor accurately detected motion, triggering predefined actions reliably.
Conclusion