IoT Based Voice Controlled Home Automation Using NodeMCU & Android App. IoT Based Voice Controlled Home Automation Using NodeMCU & Android. Previously we have made similar types of IoT based Home Automation Projects to control relay from NodeMCU web server. We have used Asyncwebserver to control home appliances from a web browser. But, today we will build our own Home Automation Android App using MIT App Inventor. Install it on Android smartphones and control our home appliances using voice commands as well as buttons.
This IoT based voice-controlled home automation project, allows you to interface 2/4/8 channel relay with NodeMCU ESP8266 and control different Appliances like Lights, Fan, AC cooler, Pump, etc. We will use an Android app having Several ON/OFF Buttons and voice-controlled system to send a signal to NodeMCU in order to control relay output.
We will assign an IP address to NodeMCU and assign the same IP Adress to the Android App. Because our Android phone and NodeMCU should be connected to the same network for access control. Hence this project is also a LAN based Project.
S.N. COMPONENTS DESCRIPTION QUANTITY
1 NodeMCU ESP8266-12E Board 1
2 Relay Module 4-Channel 5V NPN Relay Module 1
3 LED 5mm LED of Any Color 4
4 Resistor 220 ohm 4
5 Power Supply 5V, 1A Power Adapter 1
6 Connecting Wires Jumper Wires 10
7 Breadboard – 1
Block Diagram of Voice Controlled Home Automation
Here is a block diagram for this project “Voice Controlled Home Automation using ESP8266”. It is simple and easy to understand.
The relay module is interfaced with using GPIO Pins of NodeMCU. The output pin of the Relay is connected to 4 different LEDs for demonstration. ESP8266 NodeMCU is connected to your Wifi network and is capable of receiving a signal via the Internet.
Your smartphone Device has a “Home Automation Control” Android app installed on it. For controlling NodeMCU GPIOs Pins, the IP address of NodeMCU is entered on the Android App IP box.
Once you complete this setup, you can control your home appliances from the Android app staying anywhere in the world. Here, your Android phone acts as a remote controller and NodeMCU as a receiver. Actually, signals are transmitted via the internet.
|NodeMCU ESP8266 GPIOs||Relay Input Pin|
|GPIO Pin D1||Input Pin 1|
|GPIO Pin D2||Input Pin 2|
|GPIO Pin D3||Input Pin 3|
|GPIO Pin D4||Input Pin 4|
Android App Voice Controlled Home Automation
The Android App will send a string that must be interpreted by the code to activate each one of the relays defined as follows:
Home Automation App Download Link:
If you are a beginner and you don’t know to make any Android App, you can simply download the App from the link below.
Link: Download Here
You can also modify this Android App by exporting the .aia file. You can watch the video attached below for a detailed tutorial.
Link: Download Here
Code to find NodeMCU IP Address
Simply copy the code provided below and upload it to Arduino IDE. After Code is uploaded successfully. Simply click on Serial Monitor and get the IP address of NodeMCU. Now note down this IP as it is required for your Android App.
Complete Program Copy and Paste with Arduino IDE.
const char* ssid = “xxxxxxxx”;
const char* password = “xxxxxxxx”;
String command =””;
int relay1 = D1;
int relay2 = D2;
int relay3 = D3;
int relay4 = D4;
client = server.available();
if (!client) return;
command = checkClient ();
if (command == “r1on” || command == “turn on relay 1” || command == “relay 1 on”) digitalWrite(relay1,0);
else if (command == “r1off” || command == “turn off relay 1” || command == “relay 1 off”) digitalWrite(relay1,1);
else if (command == “r2on” || command == “turn on relay 2” || command == “relay 2 on”) digitalWrite(relay2,0);
else if (command == “r2off” || command == “turn off relay 2” || command == “relay 2 off”) digitalWrite(relay2,1);
else if (command == “r3on” || command == “turn on relay 3” || command == “relay 3 on”) digitalWrite(relay3,0);
else if (command == “r3off” || command == “turn off relay 3” || command == “relay 3 off”) digitalWrite(relay3,1);
else if (command == “r4on” || command == “turn on relay 4” || command == “relay 4 on”) digitalWrite(relay4,0);
else if (command == “r4off” || command == “turn off relay 4” || command == “relay 4 off”) digitalWrite(relay4,1);
else if (command == “allon” || command == “Turn on all devices” || command == “all on”)
else if (command == “alloff” || command == “Turn off all devices” || command == “all off”)
sendBackEcho(command); // send command echo back to android device
command = “”;
Serial.println(“Connecting to WIFI”);
while ((!(WiFi.status() == WL_CONNECTED)))
Serial.println(“NodeMCU Local IP is : “);
String checkClient (void)
String request = client.readStringUntil(‘\r’);
void sendBackEcho(String echo)
client.println(“HTTP/1.1 200 OK “);