Introduction: NodeMCU Home Automation (ESP8266)
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:
- Making the right hardware selection for your project depending on its functionalities.
- Understand the Home automation systems.
- Prepare the circuit diagram to connect all the choosen components.
- Assemble all the project parts (device box and electronic assembly)..
- Start the first test and validate the project.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: What Is a Home Automation System!
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.
Step 2: CAD and Hardware Parts
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.
Step 3: Circuit Diagram
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.
Step 4: PCB Making
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.
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.
Step 5: Ingredients
Before start soldering the electronic parts let’s review the components list for our project so we will need:
★☆★ The necessary components ★☆★
- The PCB that we have ordered from JLCPCB
- The NodeMCU board : https://amzn.to/2KkDoYX
- BH1750 sensor : https://amzn.to/2NKcj3t
- DHT11 sensor : https://amzn.to/2pkFPDM
- Motion sensor :https://amzn.to/2CHxvRr
- Light spots : https://amzn.to/372f08n
- DC fan : https://amzn.to/2Qe49C6
- The relays : https://amzn.to/33KXfsd
- The optocoplers : https://amzn.to/350Prmo
- Some resistors and transistors
- Some LEDs and zener diodes
- Some screw header connectors :
- Some SIL connectors
Step 6: Hardware Assembly
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.
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.
Step 7: Software Part & Test
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.
Participated in the