|
OrCad Cadance |
|
|
arduino IDEArduino
|
Home Automation Board with ESP8266 Dual Output
As technology advances, more and more people are turning to home automation to simplify their lives. From smart thermostats to voice-activated assistants, these devices are designed to make our homes more efficient and convenient.
But what if you could create your own custom home automation device tailored specifically to your needs?
In this article, we'll show you how to build your own DIY home automation device that can control everything from your lights to your coffee maker.
This DIY home automation device uses an ESP8266 to operate two independent relays to switch two outputs or loads.
The user can visit the home automation device's WEB PAGE and utilize the buttons to operate the XYZ equipment connected to two relays.
Have a look at the Home Automation Board's building project.
Material Required
These were the materials used in this built-
- Custom PCB
- ESP07S Module
- Relay 250V 10A Load side, 5V Operation
- 240V to 5V and 3.3V Isolated Power Supply
- AO3400 Mosfet
- 10K Resistors
- 1K resistors
- RED LEDs
- NODEMCU for programming the ESP07S
- M7 or SS34 Diode SMA Package
- Toggle Switch
PCB Design
The first step is to create the PCB design for the home automation board, which consists of an ESP07S Basic Setup. The ESP07S is an ESP8266 board, and like all ESP8266 boards, it simply requires four 10K resistors linked to different GPIO pins.
We include two relays in the design to control the outputs. The gates of the relays are connected to GPIOs 4 and 0, and each relay is controlled by two N-Channel Mosfets set up in a switch configuration.
Also, we connect two LEDs to GPIO15 and GPIO2, which will be added near each relay when the components are placed on the PCB layout and will serve as an indicator when the relays are toggled.
This project does not incorporate an LDO, which is typically required when working with 5V input and ESP Modules to step down the 5V into 3.3V.
We utilize an AC-isolated power supply module in place of an LDO, which converts 240V AC into 5V and 3.3V filtered DC (It has two output voltages).
After the schematic is complete, we convert it into a board design and arrange all the parts in a neat 70mm x 60mm form factor.
A few slots were placed between the AC pins and the DC components for isolation purposes, and the ESP07S configuration is located on one side of the board while the other is occupied with relays and other components.
PCB Gerber Data was sent to PCBway for samples.
PCBWAY
After the PCB Design was completed, Gerber data was generated and then sent to PCBWAY for samples.
An order was placed for the PCBs with white soldermask and black silkscreen, as its looks pretty cool in general.
The PCBs were received within a week, and they were excellent, as expected.
Really love the quality of PCBs made by PCBWAY. There are other manufacturers available, but their service is always on another level.
check out PCBWay service for getting great PCB service at less cost.
Board Assembly
- Board Assembly Process begins by first adding solder paste to each component pad one by one.
- Next, using a tweezer, we pick and position each SMD component in its designated location.
- Following that, we carefully lifted the entire circuit board and set it down on the Mini SMT Hotplate, which heats the PCB from below up to the solder paste melting temperature. As soon as the PCB reaches that temperature, the solder paste melts, and all the components are connected to their pads.
- The THT components are then assembled, and their pads are soldered using a soldering iron.
The board assembly is now complete.
RESULT so far
This complete home automation board, which has every component attached properly to its location, is the end result of the board assembly process.
We may now move on to the next step, which is programming the ESP07s so that we can use the board for controlling things.
Programming the ESP07 with NODEMCU
You might not be aware that the NODEMCU Board can be used to program any ESP board.
By taking a NODEMCU Board and connecting a jumper with its GND Pin and EN Pin, which puts the ESP8266 of the NODEMCU into sleep mode, we may utilize the NODEMCU to program the onboard ESP07S module.
This enables us to connect an external ESP Board to NODEMCU; so essentially, we are turning off the ESP board on NODEMCU and connecting a second ESP Board to a few of its pins.
You can read the article below for additional information about this process.
https://www.hackster.io/Arnov_Sharma_makes/program-esp8266-with-nodemcu-7ea1bb
TEST SKETCH
The test sketch, which is actually a chaser sketch, is uploaded to the ESP Board. Its main function is to sequentially toggle each output pin to show how the board functions.
After uploading the code, we unplug the board from the NODEMCU Programmer and attach an AC cord to the board's live and neutral connectors using a soldering iron.
The gates of the two MOSFETs that are connected to relays are attached to GPIO4 and GPIO0.
LEDs are connected to GPIO15 and GPIO2.
The chaser sketch ensures that each output is functional, allowing us to proceed to the next phase, which is to connect an AC load to the home automation board and upload the main code.
OUTPUT WIRING
The hot side wiring is straightforward: we connect an alternating current supply to the board's AC CON, as well as live and neutral wires.
Live goes to each of the relay's COM ports; the NO of both relays is connected with a CON2 port.
By wiring components with this board in accordance with the wiring design, we may add a load by connecting it to the neutral and NO of the connector. With this configuration, we could also connect two loads.
CAUTION
While working with an AC source, be sure to follow the fundamental precautions before wiring.
Do keep in mind that dealing with alternating current is dangerous and can kill you, so wear gloves, avoid touching the hot side of the board with your bare hand, and avoid lifting the board while it is connected.
Here is a hack that we can do while working with this board: We can 3D print a case for it that will isolate the AC connections and make it a little bit safer.
To test that the relay actually operates, we connected a 25W tube light to this board's Load 1 and ran TEST SKETCH. The tube light flashed rapidly, as did the other outputs that were being turned ON and OFF sequentially.
Next, we upload the main code into this board.
Home Automation Sketch
Check out the main sketch, which is attached in the code section.
- We first edit the SSID and PASSWORD in the sketch
- next we upload the code into the ESP07S Module using the NODEMCU Programmer
- after uploading, we open the serial Monitor and copy the IP Address shown when the ESP gets connected to WiFi.
- We paste the IP Address in any browser and WEB APP will open up which can be used to toggle two outputs.
The web app is completely customized and is made completely from a single sketch without using any third-party tools.
This sketch is a fusion of classic embedded C language and HTML with a little bit of CSS.
We set up the HTML page in this sketch by the below lines.
// Display the HTML web page client.println("<!DOCTYPE html><html>"); client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"); client.println("<link rel=\"icon\" href=\"data:,\">"); // CSS to style the on/off buttons // Feel free to change the background-color and font-size attributes to fit your preferences client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}"); client.println(".button { background-color: #5B196A; border: none; color: white; padding: 16px 40px;"); client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}"); client.println(".button2 {background-color: #5B196A;}</style></head>"); // Web Page Heading client.println("<body><h1>HOME AUTOMATION DUAL OUTPUT</h1>"); // Display current state, and ON/OFF buttons for OUTPUT1 client.println("<p>LOAD1 - State " + output1State + "</p>");
We have 4 outputs (two relays and two LEDs), which were declared at the start of the sketch.
const int output1 = 0; //RELAY1 const int output2 = 4; //RELAY2 const int ledPin1 = 15; //LED1 const int ledPin2 = 2; //LED2
Please note that this setup will only work if the ESP8266 and the device that you're browsing the APP on the same network. (LOCAL NETWORK OPERATION)
Conclusion
The final result of this quick project is a Dual Load Home Automation Load that can be used to control two different AC Devices via a WEB APP.
The next iteration of this project will have more relays, which will increase the outputs.
Do leave a comment if you need any help regarding this project.
This is it for today folks.
Thanks PCBWAY for supporting this project, you guys can check them out if you need great PCB and stencil service for less cost and great quality.
And I'll be back with a new project pretty soon!
int pinsCount=5; // declaring the integer variable pinsCount
int pins[] = {0,4,15,2}; // declaring the array pins[]
void setup() {
pinMode(0, OUTPUT);
pinMode(4, OUTPUT);
pinMode(15, OUTPUT);
pinMode(2, OUTPUT);
}
void loop() {
for (int i=0; i<pinsCount; i=i+1){ // chasing right
digitalWrite(pins[i], HIGH); // switching the LED at index i on
delay(70); // stopping the program for 100 milliseconds
digitalWrite(pins[i], LOW); // switching the LED at index i off
}
for (int i=pinsCount-1; i>0; i=i-1){ // chasing left (except the outer leds)
digitalWrite(pins[i], HIGH); // switching the LED at index i on
delay(70); // stopping the program for 100 milliseconds
digitalWrite(pins[i], LOW); // switching the LED at index i off
}
}
#include <ESP8266WiFi.h>
// Replace with your network credentials
const char *ssid = "YOUR SSID";
const char *password = "YOUR PASS";
// Set web server port number to 80
WiFiServer server(80);
// Variable to store the HTTP request
String header;
// Auxiliar variables to store the current output state
String output1State = "off";
String output2State = "off";
// Assign output variables to GPIO pins
const int output1 = 0; //RELAY1
const int output2 = 4; //RELAY2
const int ledPin1 = 15; //LED1
const int ledPin2 = 2; //LED2
void setup() {
Serial.begin(115200);
// Initialize the output variables as outputs
pinMode(output1, OUTPUT);
pinMode(output2, OUTPUT);
//LEDs
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
// Set outputs to LOW
digitalWrite(output1, LOW);
digitalWrite(output2, LOW);
// Connect to Wi-Fi network with SSID and password
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Print local IP address and start web server
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
server.begin();
}
void loop(){
WiFiClient client = server.available(); // Listen for incoming clients
if (client) { // If a new client connects,
Serial.println("New Client."); // print a message out in the serial port
String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
header += c;
if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
// turns the GPIOs on and off
if (header.indexOf("GET /1/on") >= 0) {
Serial.println("LOAD1 on");
output1State = "on";
digitalWrite(output1, HIGH);
digitalWrite(ledPin1, HIGH);
} else if (header.indexOf("GET /1/off") >= 0) {
Serial.println("LOAD1 off");
output1State = "off";
digitalWrite(output1, LOW);
digitalWrite(ledPin1, LOW);
} else if (header.indexOf("GET /2/on") >= 0) {
Serial.println("LOAD2 on");
output2State = "on";
digitalWrite(output2, HIGH);
digitalWrite(ledPin2, HIGH);
} else if (header.indexOf("GET /2/off") >= 0) {
Serial.println("LOAD2 off");
output2State = "off";
digitalWrite(output2, LOW);
digitalWrite(ledPin2, LOW);
}
// Display the HTML web page
client.println("<!DOCTYPE html><html>");
client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
client.println("<link rel=\"icon\" href=\"data:,\">");
// CSS to style the on/off buttons
// Feel free to change the background-color and font-size attributes to fit your preferences
client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
client.println(".button { background-color: #5B196A; border: none; color: white; padding: 16px 40px;");
client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");
client.println(".button2 {background-color: #5B196A;}</style></head>");
// Web Page Heading
client.println("<body><h1>HOME AUTOMATION DUAL OUTPUT</h1>");
// Display current state, and ON/OFF buttons for OUTPUT1
client.println("<p>LOAD1 - State " + output1State + "</p>");
// If the output1State is off, it displays the ON button
if (output1State=="off") {
client.println("<p><a href=\"/1/on\"><button class=\"button\">ON</button></a></p>");
} else {
client.println("<p><a href=\"/1/off\"><button class=\"button button2\">OFF</button></a></p>");
}
// Display current state, and ON/OFF buttons for GPIO 4
client.println("<p>LOAD2 - State " + output2State + "</p>");
// If the output4State is off, it displays the ON button
if (output2State=="off") {
client.println("<p><a href=\"/2/on\"><button class=\"button\">ON</button></a></p>");
} else {
client.println("<p><a href=\"/2/off\"><button class=\"button button2\">OFF</button></a></p>");
}
client.println("</body></html>");
// The HTTP response ends with another blank line
client.println();
// Break out of the while loop
break;
} else { // if you got a newline, then clear currentLine
currentLine = "";
}
} else if (c != '\r') { // if you got anything else but a carriage return character,
currentLine += c; // add it to the end of the currentLine
}
}
}
// Clear the header variable
header = "";
// Close the connection
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
}
Home Automation Board with ESP8266 Dual Output
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(1)
- Likes(0)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Arnov Arnov sharma
- WALKPi PCB Version Greetings everyone and welcome back, This is the WalkPi, a homebrew audio player that plays music fr...
- Delete Button XL Greetings everyone and welcome back, and here's something fun and useful.In essence, the Delete Butt...
- Arduino Retro Game Controller Greetings everyone and welcome back. Here's something fun.The Arduino Retro Game Controller was buil...
- Super Power Buck Converter Greetings everyone and welcome back!Here's something powerful, The SUPER POWER BUCK CONVERTER BOARD ...
- Pocket Temp Meter Greetings and welcome back.So here's something portable and useful: the Pocket TEMP Meter project.As...
- Pico Powered DC Fan Driver Hello everyone and welcome back.So here's something cool: a 5V to 12V DC motor driver based around a...
- Mini Solar Light Project with a Twist Greetings.This is the Cube Light, a Small and compact cube-shaped emergency solar light that boasts ...
- PALPi V5 Handheld Retro Game Console Hey, Guys what's up?So this is PALPi which is a Raspberry Pi Zero W Based Handheld Retro Game Consol...
- DIY Thermometer with TTGO T Display and DS18B20 Greetings.So this is the DIY Thermometer made entirely from scratch using a TTGO T display board and...
- Motion Trigger Circuit with and without Microcontroller GreetingsHere's a tutorial on how to use an HC-SR505 PIR Module with and without a microcontroller t...
- Motor Driver Board Atmega328PU and HC01 Hey, what's up folks here's something super cool and useful if you're making a basic Robot Setup, A ...
- Power Block Hey Everyone what's up!So this is Power block, a DIY UPS that can be used to power a bunch of 5V Ope...
- Goku PCB Badge V2 Hey everyone what's up!So here's something SUPER cool, A PCB Board themed after Goku from Dragon Bal...
- RGB Mixinator V2 Hey Everyone how you doin!So here's a fun little project that utilizes an Arduino Nano, THE MIXINATO...
- Gengar PCB Art Hey guys and how you doing!So this is the GENGAR PCB Badge or a Blinky Board which is based around 5...
- R2D2 Mini Edition So here's something special, A Mini R2D2 PCB that speaks ASTROMECH.Astromech is a fictional language...
- C-3PO Blinky Board Hey guys and how you doing!So this is the C3P0 PCB Badge or a Blinky Board which is based around 555...
- WALKPi Breadboard Version Greetings everyone and welcome back, Here's something loud and musical.Similar to a traditional walk...
-
-
-
kmMiniSchield MIDI I/O - IN/OUT/THROUGH MIDI extension for kmMidiMini
121 0 0 -
DIY Laser Power Meter with Arduino
172 0 2 -
-
-
Box & Bolt, 3D Printed Cardboard Crafting Tools
162 0 2 -