The objective of this project is to create a cutting-edge home automation solution utilizing the ESP32 device. The system aims to enable remote management and monitoring of household appliances and devices, enhancing homeowners' control, convenience, and energy efficiency, particularly concerning AC appliances.
This project is the first prototype for my actual home automation idea. The main idea behind the project is to create a credit card-sized home automation system that fits inside the switchboard and connects to the existing wiring to control up to 8 AC appliances. The project allows users to use the existing switchboard as it is to control the ac appliance in addition to that it also allows users to control their ac appliances using a web dashboard or a mobile app via the internet, also using an ir remote. The project features 3 sensors that can be sued to automate a certain task, for example, the project has a temperature sensor connected to it, if the value of the temperature sensor goes above a certain value, the user can configure it to automatically turn on appliances like air conditioners or fans, etc.
The app or the web dashboard allows users to seamlessly control their appliances and it also helps them to automatically turn the devices on using timers.
The app or web dashboard also helps users to visualize their usage through beautiful charts and helps users to predict the electrical expenses.
The project also provides predictions on when the user is there in the home and when he leaves using daily usage analysis.
Components Required
- ESP32-wroom32 module ->1pc
- 5V sugar cube relays ->8pc
- BC547 transistors ->8pc
- IN4007 diode ->8pc
- 300 OHM resistor ->8pc
- 1K OHM resistor ->8pc
- EL817C optocoupler ->8pc
- 220 OHM resistors ->1pc
- 5v led ->1PC
- 10UF 50v capacitor ->4pc
- AMS117 5V/1A ->1pc
- AMS117 3.3V/1A ->1pc
- 2pin PCB mount terminal block ->9pc
- HILINK 12V/3W ->1pc
- TXS108E logic converter ->1pc
- berg strips/male headers ->2pc(80pins)
- jumper wires ->as needed
- sensors ->as needed(DHT sensor preferred)
- Custom PCB ->1pc
- TSOP38238 IR receiver head ->1pc
- IR remote for TSOP38238 ->1pc
Circuit Diagram
The actual project circuit has been uploaded in the images section. The prototype of this project has an led that indicates if a device is on or not, the led is connected to the gpio2 of the esp32 development board. There is a switch that is connected to the gpio4 of the esp32 development board. the user can use the switch to control the led or us use the web dashboard.
In the actual project idea, the plan was to create a custom PCB and solder all the components.
The actual project idea basically consists of a PCB with 8 inbuilt relay modules with optocouplers,3 sensors connected to the esp32, ac to dc 12v link module, voltage regulators, logic converter, and an esp32 actual module instead of a development board.
PCB Design
3D Model
Arduino Code
Libraries: -
- WiFi.h: Manages WiFi connections.
- HTTPClient.h: Enables HTTP communication.
- Arduino.h: Provides built-in functions.
Constants and Variables: -
- serverAddress: Webserver URL.
- ssid: WiFi SSID.
- password: WiFi password.
- RelayPins[8]: GPIO pins connected to relays.
- SwitchPins[8]: GPIO pins connected to switches.
- SwitchStates[8]: Tracks switch states.
- Response: Holds server response.
- url: Webserver URL.
- httpGetCode: HTTP GET response code.
- httpPostCode: HTTP POST response code.
- Esp_Http_Client: HTTPClient instance.
Functions: -
http_get(): Sends HTTP GET request to server.
http_post(int flag): Sends HTTP POST request.
print_relay_states(): Prints device states.
modify_relays(): Adjusts relays based on Response.
switch_state_change(): Detects changes in switch states.
modify_response(): Updates Response based on switches.
manual_mode(): Handles offline mode.
Setup Function: -
- Initializes serial communication.
- Connects to WiFi.
- Sets pin modes for relays and switches.
- Initializes switch states.
Loop Function: -
If WiFi connected: -- Sends HTTP GET, checks relay changes.
- If switch changes, updates Response, sends POST.
- Modifies relay states from Response.
If WiFi not connected: -
- Enters manual mode.
- Checks switch changes, updates relays.
- Prints relay states.