Automate your house hold appliances with this simple tutorial. With open source softwares and components available in plenty , create your own creative DIY‘s.
The tutorial provides you with step by step process of creating android app and controlling home appliances over internet using ESP8266 wifi chip.
While going through this tutorial a little familiarity with Arduino is required. The programming code is be written for ESP8266 wifi chip using Arduino IDE, for which installation of ESP8266 library is required. Click here to setup library for ESP.
Inthis tutorial NodeMCU V1.0 has been used, which is ESP8266 breakout board with usb-ttl option. This provides for easy connection to your PC and arduino IDE. If you are connecting Node MCU board for the first time you would require usb drivers. These drivers could be download by clicking here.
Step 1:
After Connecting Node MCU(Multi-point Control unit) to PC , open Arduino IDE, set com port and choose NODE MCU 1.0 from board as circled in the image below.
Board and Port Selection Fig. 1 Board and Port Selection
Step 2:
Copy the below code to IDE.
/*
* This sketch demonstrates how to set up a simple HTTP-like server.
* The server will set a GPIO pin depending on the request
* http://server_ip/gpio/0 will set the GPIO2 low,
* http://server_ip/gpio/1 will set the GPIO2 high
* server_ip is the IP address of the ESP8266 module, will be
* printed to Serial when the module is connected.
*/
#include <ESP8266WiFi.h>
constchar*ssid=“myHomeWifiName”;
constchar*password=“MyWifiPassword”;
// Create an instance of the server
// specify the port to listen on as an argument
WiFiServerserver(80);
voidsetup(){
Serial.begin(115200);
delay(10);
// prepare GPIO2
pinMode(2,OUTPUT);
digitalWrite(2,0);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print(“Connecting to “);
Serial.println(ssid);
WiFi.begin(ssid,password);
while(WiFi.status()!=WL_CONNECTED){
delay(500);
Serial.print(“.”);
}
Serial.println(“”);
Serial.println(“WiFi connected”);
// Start the server
server.begin();
Serial.println(“Server started”);
// Print the IP address
Serial.println(WiFi.localIP());
}
voidloop(){
// Check if a client has connected
WiFiClientclient=server.available();
if(!client){
return;
}
// Wait until the client sends some data
Serial.println(“new client”);
while(!client.available()){
delay(1);
}
// Read the first line of the request
Stringreq=client.readStringUntil(‘\r’);
Serial.println(req);
client.flush();
// Match the request
intval;
if(req.indexOf(“/gpio/0”)!=–1)
val=0;
elseif(req.indexOf(“/gpio/1”)!=–1)
val=1;
else{
Serial.println(“invalid request”);
client.stop();
return;
}
// Set GPIO2 according to the request
digitalWrite(2,val);
client.flush();
// Prepare the response
Strings=“HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nGPIO is now “;
s+=(val)?“high”:“low”;
s+=“</html>\n”;
// Send the response to the client
client.print(s);
delay(1);
Serial.println(“Client disonnected”);
// The client will actually be disconnected
// when the function returns and ‘client’ object is detroyed
}
Step 3:
In the above code mention the wifi network SSID and Password as shown below:
const char* ssid = “You WIFI SSID Name”;
const char* password = “your wifi password”;
Step 4:
Compile and Upload code to Node MCU(Multi-point Control unit) and this brings us to the end of coding part.
Step 5:
Now, Open Serial Terminal of Arduino IDE and press reset button on ESP8266. Now it will connect to your wifi network and show you an IP address in terminal.
Step 6:
Go to your browser enter URL like below
http://YourESP8266IPAddress/gpio/0 will set the GPIO2 low,
http://YourESP8266IPAddress/gpio/1 will set the GPIO2 High,
You can observe that the Node MCU(Multi-point Control unit) LED toggles between on and off when you press the above URL.
Due to unavailability of time-critical information, challenges like operational efficiency and safety affect the productivity of employees and the overall industry of manufacturing. With...
A good battery gives an electric vehicle the power to traverse long distances without any tension. But when upgraded with next-gen technology such as...
Indian population provides vast market, opines Shanghai-headquartered Quectel
As India is all set to launch the 5G services in the coming weeks, the global IoT...
IoTecha’s IoT.ON™ EV charging platform, featuring both 40A and 80A level 2 EV chargers, has been added to the Southern California Edison (SCE) Charge...
Pollin8, a Kiwi IoT SaaS company, and Thinxtra, an Australian IoT telco, have deployed an asset tracking solution to New Zealand glass maker Architectural...
Reportlinker.com announces the release of the report "5G Services Global Market Report 2022" The global 5G services market is expected to grow from $40.0...
Any 5G device that has been upgraded to Rel 17 NTN can directly connect to the satellite using an onboard module that supports NB-IoT.
Barcelona-based...
Private drinking water wells will be kept in good condition with the help of 5G IoT satellite communication, according to the Spanish nanosatellite business Sateliot...
Nordic Semiconductor and Wirepas have joined the DECT Forum to support the comeback of wireless technology for the Internet of Things.
The most recent DECT...
Remote attacks stand to be the most prevalent danger. The cybersecurity company claimed that Lanner has developed fixes that should address the 13 vulnerabilities,...