NodeMCU Home Automation (ESP8266)

by DIY GUY Chris in Circuits > Electronics

6169 Views, 10 Favorites, 0 Comments

NodeMCU Home Automation (ESP8266)

NodeMCU Home automation ESP8266 smart house
Diapositive7.PNG

Hey guys! I Hope you already enjoyed my previous instructable "Arduino Heart Beat With ECG Display & Sound" and you are ready for a new one, as usual I made this tutorial to guide you step by step while making this kind of super amazing low cost electronic projects which is the "NodeMCU Home automation system".

During the making of this project, we tried to make sure that this instructable will be the best guide for you in order to help you if you want to make your own Smart house, so we hope that this instructable contain the needed documents. This project is so handy to make specially after getting the customized PCB that we’ve ordered from JLCPCB to improve the appearance of our electronic device and also there is enough documents and codes in this guide to allow you create your NodeMCU project easily.

We've made this project in just 4 days only, just two days to get all the needed parts and finish the hardware making and the assemble, then we have prepared the code to suit our project and start the testing and the adjustment.

What you will learn from this instructable:

  1. Making the right hardware selection for your project depending on its functionalities.
  2. Understand the Home automation systems.
  3. Prepare the circuit diagram to connect all the choosen components.
  4. Assemble all the project parts (device box and electronic assembly)..
  5. Start the first test and validate the project.

What Is a Home Automation System!

Diapositive3.PNG
Diapositive4.PNG
Diapositive5.PNG

A home automation system is simply a system that allows some users to have access to some electrical devices like lightning devices temperature monitoring doors control devices etc and this access is monitored through a basic application connected to the main system through a wireless or wired protocol, about the automation part, the system is able to adjust some environmental parameters automatically using some actuators and some sensors, for example the system can read temperature data from a temperature sensor and decides to turn on or to switch off an air-conditioner.

In our project we will create the main system which is an electronic circuit board based on a NodeMCU dev board which already has a wifi feature in it and this board will be surrounded by some electronic components like relays optocoplers LEDs and sensors, about the sensors we will use the motion sensor for an alarm detection, a DHT11 for temperature and humidity measuring and BH1750 for light sensing.

About the actuators, we will control some 220V AC bulbs and a DC fan and all these actuators will be controlled through an android app that we have developed through Blynk application. So in this application I inserted some gauges to read the analog values from the sensors and I placed some buttons and sliders to control my outputs.

CAD and Hardware Parts

solid1.JPG
solid2.JPG
20191105_203651.jpg
20191105_203658.jpg
20191105_203701.jpg

I used solidworks software to design this house model which already has sockets for the lightning spots the sensors and the fan, you can get the STL files from the download link down below, after preparing the design I have got my parts very well produced through a CNC laser cutting.

Circuit Diagram

Schematic_NodeMCU-smart-house_NodeMCU-smart-house_20190625003426.png

Moving to the electronics, I have created this circuit diagram that includes all the necessary parts required for this project. I am connecting the realys outputs to my NodeMCU Dev board and I use the DHT11? BH1750 and the motion sensors connected to the I²C port and to the ADC input, also I used the only PWM output of my NodeMCU Dev board and I connected it to a screw terminal in order to control the brightness of some LEDs, I used separated power supply for the relays and the NodeMCU and this way I will protect my Dev board while controlling the 220V AC voltage.

PCB Making

Smart house2.JPG
Smart house1.JPG
Smart house4.JPG
Smart house3.JPG
20191027_101325.jpg
20191027_101353.jpg

About JLCPCB

JLCPCB (Shenzhen JIALICHUANG Electronic Technology Development Co., Ltd.), is the largest PCB prototype enterprise in China and a high-tech manufacturer specializing in quick PCB prototype and small-batch PCB production. With over 10 years of experience in PCB manufacturing, JLCPCB has more than 200,000 customers at home and abroad, with over 8,000 online orders of PCB prototyping and small quantity PCB production per day. The annual production capacity is 200,000 sq.m. for various of 1-layer, 2-layer or multi-layer PCBs. JLC is a professional PCB manufacturer featured of large scale, well equipment, strict management and superior quality.

Talking electronics

After making the circuit design I transformed this circuit into a customized PCB design with a house shape in order to get a beautiful PCB design when we order our circuit and to do so all what I need is to move to JLCPCB the best PCB supplier in order to get the best PCB manufacturing service, after some simple clicks I have uploaded the appropriate GERBER files of my design and I set some parameters and this time we will use the black color for this project with a golden spots; just four days after placing the order and my PCBs are on my desktop.

Related download files

As you can see in the pictures above the PCB is very well manufactured and I’ve got the same PCB design that we’ve made for our main board and all the labels,logos are there to guide me during the soldering steps. You can also download the Gerber file for this circuit from the download link below in the case you want to place an order for the same circuit design.

Ingredients

20191105_203352.jpg

Before start soldering the electronic parts let’s review the components list for our project so we will need:

★☆★ The necessary components ★☆★

Hardware Assembly

20191105_221721.jpg
20191105_222654.jpg
20191105_222530.jpg
20191110_162540.jpg
20191110_162534.jpg
20191110_162546.jpg
20191110_171700.jpg
20191111_185856.jpg
20191110_170413.jpg
20191110_170939.jpg
20191111_195424.jpg
20191111_195429.jpg

Now everything is ready so let’s start soldering our electronic components to the PCB and to do so we need a soldering iron and a solder core wire and a SMD rework station for SMD components.

Safety first

Soldering Iron Never touch the element of the soldering iron....400°C! Hold wires to be heated with tweezers or clamps. Always return the soldering iron to its stand when not in use. Never put it down on the workbench. Turn unit off and unplug when not in use. As you can see, using this PCB is so easy due to its very high quality making and without forgetting the labels that will guide you guys while soldering each component because you will find on the top silk layer a label of each component indicating its placement on the board and this way you will be 100% sure that you will not make any soldering mistakes.I’ve soldered each component to its placement and you can use both sides of the PCB to solder your electronic components.

Software Part & Test

Code1.JPG
code2.JPG
code3.JPG
20191112_161143.jpg

Now we have the PCB ready and all the components soldered very well an after finishing the assembly we need to move to the software part I have made this NodeMCU code for you guys using the Arduino IDE and if you still don’t know how to use NodeMCU boards with Arduino IDE just check this guide video that we are providing , about the code we will test first the circuit board that we have made with a testing code testing code that allows you to control the LEDs of the board. Once you run your Blynk application, you will find the selected NodeMCU board already online (if you use the token provided by Blynk in your code). Now all what we need is the final code that you can have for free from the download link below, the code is very well commented so you can understand it and adjust it for your own needs.