Internet/cloud Controlled Home Automation Using Esp8266 (aREST, MQTT, IoT)


Only 4 components required –

1. ESP8266 NODEMCU or WEMOS D1 mini or any esp8266 wifi development board
2. RELAY (5V or 6V)
3. ULN2003 or UNL2003A (Relay driver IC)
4. Jumpers (obviously or else solder it!!)

The main structure of the project is that

ESP8266 module will receive the signal from the MQTT server (i.e. and forward the signal to the pin or processor. ULN2003 relay driver IC connected to the Nodemcu board pins. Output pins are connected to relay or any RGB light or servo motor etc.

Step 2: Software

I have used Arduino IDE as the programming software. If you are new to this Nodemcu or esp8266 development board then please refer to my previous instructable. To interface the Nodemcu or wemos board with Arduino IDE.

In the Arduino IDE after setting up previous told things, go to SKETCH -> INCLUDE LIBRARY -> MANAGE LIBRARIES -> SEARCH FOR “arest” -> INSTALL THE LIBRARIES -> NOW SEARCH FOR PubSubClient -> INSTALL THE LIBRARY.

Now its half done… almost there!!!


As the above circuit depicts everything still the input side of the ULN2003 relay driver IC is connected to the pins of the esp8266 and the output is connected to relay’s coil leg as when esp8266 pin gets high the output pin of ULN2003 gets low thus giving the relay a 5V potential to work.

Instead of sending the 0 or 1 to the relay esp8266 pins we can also send other values for servo but declaring servo.attach(pin) to rotate the servo to the certain value. Its easy but everyone need to innovate, read and think a little.

Step 4: CODE

I got the idea from “Marco Schwartz” project and modified it. He have use d the MQTT but we can also use The main part of the program is :

Unique 6digit arest id

char* device_id = “unique_6_digit_id”;

WiFi credentials

const char* ssid = “ssid_name”; const char* password = “your_password”;

Choose any unique id as you like but it should be unique not my or your name unless its a telugu name!!

example of unique id: pf4h6q (just example)

there can be many changes made in the code as according to the code, we have to mention the output after every reboot of the development board.

Github code



2 CRUCIAL steps:

1. declaring output pin
2. toggling or sending information in that pin

Declaring output pin:

“pf486q” is the 6 digit unique code for

“o” as output

reply after executing this in any browser {“message”:”Pin D2 set to output”,”id”:”pf486q”,”name”:”home cloud”,”hardware”:”esp8266″,”connected”:true}

Toggling or sending information in the pin:

digital pin 2 is send a bit “0” or “1” as we wish

Declaring pin is necessary for once after a reboot/reset/shutdown otherwise for continuous run of esp8266 it’s unnecessary.

I have used an Android app HTTPRequest to create widget on home-screen with the necessary URL. As shown in my previous instructable. Please view that otherwise this will be lengthy.


This is an IoT project for controlling home appliances, door, window, everything and can be customized according to individual’s need. Its not locally controlled, this whole thing can be controlled from anywhere.

EACH COMMAND OR URL WITH ARGUMENT NEEDS SOMETIME 1-2 second/s to execute as this is not a dedicated server… but to control your house from anywhere in this world is AWESOME!!


Thanks to “” MQTT services and to “Marco Schwatrz“…

if you like the instructable support and enjoy… and for any problem regarding this ask me.

Source: Internet/cloud Controlled Home Automation Using Esp8266 (aREST, MQTT, IoT)

About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation, and engineering. I have a clear and simple writing style and am skilled in using infographics and diagrams. I am a great researcher and is able to present information in a well-organized and logical manner.

Scroll to Top