IoT PPT07 Demo1 Smart Home ESP8266
IoT PPT07 Demo1 Smart Home ESP8266
“Try not to become a man of success. Rather become a man of value.” – Albert Einstein
System Diagram
Login TP-Link WiFi using given IP (192.168.0.1) and password written on its label.
Do the following:
Go to Quick Setup and click on Next.
Choose Operation Mode as Wireless Router and click on Next.
Select WAN Connection Type as Static IP and click on Next.
Set the Static IP, Subnet Mask, Default Gateway, Primary DNS Server, Secondary
DNS Server and click on Next.
Select the radio bands (2.4 GHz and/or 5 GHz) and click on Next.
Setup the Wireless radio bands selected above and click on Next.
Confirm the setup by clicking on Save. The router reboots and reconnects.
********
• You should be able to access Internet in your Mobile/Laptop using TP-Link WiFi AP
• To send data to ThingSpeak, we need unique write API key and Channel ID, which
will be used later in code to upload the data to ThingSpeak website
• Click on “API Keys” button to get your unique “Write API Key”
• “Channel ID” is also given on the top
14-08-2024 Dr. Manas Khatua 22
IoT Network Configuration
• When the Arduino IDE first opens, this is what you should see:
• Scroll down, select the ESP8266 board menu and install “esp8266 by ESP8266
Community”
const char* softAPssid = "ESP1_Server"; //SSID of the hotspot of ESP8266 acting as local server
const char* password = "12345678"; //Password of the hotspot of ESP8266 acting as local server
const char* wifissid = “TP-Link_A522"; //Replace with SSID of WIFI router providing internet access
const char* pass = "12345678"; //Password of WIFI router providing internet access
IPAddress server(172,16,117,192); // Static IP address of local server. Replace whatever you want.
WiFiClient client;
• Install the DHT11 library and Adafruit Unified Sensor library for DHT11 sensor
14-08-2024 Dr. Manas Khatua 50
Cont…
void setup() {
Serial.begin(9600); //serial communication at baud rate of 9600 for debugging purpose
delay(10);
dht.begin(); // start Temperature and Humidity sensor
WiFi.mode(WIFI_STA); // ESP8266 mode as station mode
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
Serial.println();
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.println("WiFi connected");
Serial.print("LocalIP:"); Serial.println(WiFi.localIP());
Serial.println("MAC:" + WiFi.macAddress());
Serial.print("Gateway:"); Serial.println(WiFi.gatewayIP());
Serial.print("AP MAC:"); Serial.println(WiFi.BSSIDstr()); // MAC address of access point
}
Compilation
successful
message in
bottom left
corner.
Serial Monitor
of Local Server
Serial Monitor
of ESP2
Serial Monitor
of ESP3
Serial Monitor
of ESP4
Serial Monitor
of ESP5