Introduction: Android Home (control Your Home From Your Phone)
My final plan is to have my house on my pocket, its switches,sensors and security. and then auto mate it
Introduction:Hi there Ich bin zakriya and this "Android home" is my project, this project is first from four upcoming instructables,
In yothis Instructable we will learn to use Mqtt with node Mcu Esp 8266 to control and monitor some switches from anywhere around the world. for the controller we will create an app in MIT app inventor. In next projects we will add sensors, camera module and then finally automate the system.
There will be three basic steps to DIY it.
step 1: Developing Android application: We will you open source online software MIT inventor for developing the app.
Step 2: Setting up node MCU Esp 8266: it consist of two parts, one is hardware setting and other is programing the node.
step 3: Understanding Mqtt and working with it: in this step we will understand the basic protocol and learn to use the setup.
>Maximum time to switch a led is approximately 0.68 sec.
1-one node Mcu esp 8266 : https://www.ebay.com/itm/Node-MCU-V3-2-Arduino-ESP8266-ESP-12-E-Lua-CH340-WiFI-WLan-IoT-Lolin-Micro-flYfE/174098423523?hash=item2889131ee3:g:xKQAAOSwHu5cHIhE
2-one eight channel relay module: https://www.ebay.com/itm/5V-eight-8-Channel-Relay-Module-For-PIC-AVR-DSP-ARM-Arduino-CAPT2011/223308111375?hash=item33fe335e0f:g:ZTsAAOSwbc5augET
3- an external 5v(2A) power source.
Step 1: Developing the Android Application.
Creating an application in MIT app inventor is very easy. you just have to plug and play. the blocks diagram is attached.
1- Whenever the app is initialize, is send a message to Node Mcu Esp8266 "data_request"
2- Whenever it gets some message(In form "1-0" which mean one is off), APP compares it and set the Colors of buttons accordingly.
3- whenever a button is pressed is it send a message to toggle the state of that button in node mcu "states"list.
and turn the button gray.(its receive now color from node mcu message)
Editable Aia file: https://drive.google.com/file/d/1al2oIpTWLK6c0PrUl...
Step 2: Step 2(a): Setting Up the Node Mcu Esp2866.
PART 1:Hardware Part.
hardware is pretty straight forward follow the given systemic and you are good to go but you are good to go.
Note:node mcu digital pin output 3.3v logic level, which is insufficient for relay board, so you need an external power supply, which will power the relays as well as the node. external power supply must atleast be (5v,2A)
pin connections are mentioned in the diagram.
Step 3: Step2(b):programming the Node Mcu
step1: install esp 8266 board in arduino ide
step2: selecting the right com pin.
step 3: download the "Relay_control.ino and run it"
step 4: install the given libraries to arduino ide." Adafruit_MQTT.h "
step 5: burn it into your node mcu
note: dont forget to add your issd,password,topic_cmd and topic_state in program.
note:the program is well commented and hopefully it will be easy, but if you get confuse anywhere let me know
Step 4: Step 3:understanding Mqtt
Mqtt (Message Queuing Telemetry Transport) is a light weight messaging protocol for devices to comunicate ,it have three basic components.
1.Subscriber: Subscriber is the device which join to the mqtt server to get data and messages from the server
2.publisher: Publisher is the device which join to the mqtt server to upload a message or data on server
3.broker: broker is the server, which keep and monitor the messages from publishers to subscribers.
>publishers,subscribers are also known as client of that server
>a broker can have multiple subscribers and publishers
WHAT IS TOPIC:
one broker will have thousands of massages,to ensure transfer of message, the publisher will send data its messages to specific address,at the same address the subscriber will get those messages. that address is called topic. In our project wi have to topics, 1 states for node mcu to publish and mobile to subscribe and one for cmds
for androids to publish and node to subscribe.
Finally: to download .apk file(which is also not allowd to upload) you will go to "MIT APP INVENTOR" . create account, load .aia type and then download .apk from "build"
If you have any type of question or query let me know, and i would love to know if you want me to work for you on your project.