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

About: Nothing just a tech enthusiast and by degree an Electrical Engineer

ALL credits to http://arest.io/ for the cloud service!!

IoT the most discussed subject in the world right now!! Cloud servers and services making this possible is the attraction point of today's world...

RULING OUT THE DISTANCE BARRIER was and is the aim!!

So now control your home or office from anywhere in the world... not from only inside or a range!!

Easiest and cheapest solution from the laziest guy!!! ENJOY AND BE LAZY...

NOTE: READ THE WHOLE PROJECT FIRST IT WILL TAKE 3-4 MINUTES AND INNOVATE... DON'T HALF READ AND BRICK YOUR DEVICE...

Step 1: COMPONENTS REQUIRED

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. arest.io) 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!!!

Step 3: CIRCUIT DIAGRAM

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 arest.io MQTT but we can also use adafruit.io. 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

Code: https://github.com/abhrodeep/Arduino_projs

Step 5: CONTROLLING

2 CRUCIAL steps:



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



Declaring output pin:

http://cloud.arest.io/pf486q/mode/5/o

"pf486q" is the 6 digit unique code for arest.io

"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:

https://cloud.arest.io/pf486q/digital/2/0

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

https://cloud.arest.io/pf486q/digital/2/1

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.

Step 6: CONCLUSION

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!!

ENJOY AND BE LAZY... BE ABSENTMINDED AND FORGET TO SWITCH OFF APPLIANCES BUT WITHOUT A HEADACHE!!!!

Thanks to "arest.io" MQTT services and to "Marco Schwatrz"...

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


Step 7: Video!!!

Someone special helped me to check it works from somewhere else or not... AND it works from anywhere just internet access is needed... (I'M in Kolkata,IN and she is in Ranchi,IN)... and yes she messed with me after knowing my unique code of arest.io so don't share your own created unique code!!