Introduction: Home Automation Using MQTT and NodeMcu or Arduino
Home automation is a new buzz now a days ..there is so many open source hardware available to build your own home automation. So many tools, its easy to confuse you to decide which is best /suitable for you. Keeping cost in mind and the basic requirement in mind you can find the best and cost effective solution in this instructable to get started with your first automation project.
Introduction to tools used in this instructable:
Target of this instruct able is to control your home appliance by your android phone.
When the you pews the button in your phone light or fan in your home turns on or off.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Tools
in a simple language when you want to communicate to your controller through mobile or a web browser you need a communication protocol and MQTT does that magic. MQTT is a message queuing telemetry transport. It is specifically designed for automation. So where does it do magic?? its a light weight protocol, what is light weight means?? Well it's having a very low footprint to send and receive data. So it uses very less amount of data to send and receive and mobile app using MQTT also consumes less battery.
So MQTT is the best for This project.
There is a lot more info at MQTT. org for those who already familiar with MQTT can skip following peragraph, for biginers read for MQTT introduction.
MQTT works on publish subscribe events. It requires MQTT broker in between. Forgot all these thing I explains MQTT with our example.
When you press the switch in your mobile or any web device you are telling your controller that you want to turn on the switch. Now as in MQTT protocol MQTT broker seats in between your mobile device and controller. Broker take care of successfully transfer your command to the controller. this is the basic. MQTT is very vast subject. To learn more about MQTT visit MQTT.org
Step 2: Mobile App.
Download the android mobile app attached here. and install in your mobile.
Go to MQTT Setting Tab and add your broker name and Port.
It require a web socket so enter the web socket port of your broker. For test.mosquitto.org web socket enabled port is 8080.
Step 3: Mobile App Configuration
Open App in your mobile and
1. Go to device setting.
2. Select new device.(when you do configuration 1st time only new device option is available).
3. Device name: you can give any name for your device in my case its lamp.
4. Device type: switch(leave as it is).
5. Topic: give topic for MQTT.
6. On command: This payload will be send when switch turn on.
7. Off command: This pay load will be send when you toggle switch to off.
8. Pess DONE button.
9. Go to Dashboard. you can see your device is generated.
10. follow all step for FAN configuration.
Step 4: Test Configuation
For testing configuration many tools are available but i prefer MQTTlens. It a chrome addon.
- launch MQTTlens.
connection name: any
Subscribe with the topic you inserted in device setting.
toggle switch in your mobile you can see response in MQTTlens.
Step 5: Hardware
So software part is over here. Hardware is the most common and so many instructables are available. If you interested in my HW than leave comment. I will explain. But trust me lot of material out there to build NodeMcu based hardware.