Created
October 22, 2019 07:07
-
-
Save futechiot/4a2fcfeda1b619eff670c7bc2e2eb335 to your computer and use it in GitHub Desktop.
Give your ESP8266 a internet connection by connecting it with your wifi router.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
OUTCOME: Connecting your ESP8266 to any Wifi NETWORK(Mobile Hotspot,Home Route) | |
Author: Ankit Rana (Futechiot) | |
Board Used: Wemos d1 mini, Wemos d1 mini pro, Node MCU | |
Website: www.futechiot.com | |
GitHub: https://github.com/futechiot | |
Rrsource: | |
Advanced IP Scanner: https://www.advanced-ip-scanner.com/ | |
-->download and open this application | |
-->Scan for networks, make sure your PC and board are connected in same network | |
-->search for obtained IP, see in manufracturer "ESPRESSIF" | |
*/ | |
#include <ESP8266WiFi.h> //Wifi library of esp8266 to access HARDWARRE APIS and othe functionality | |
/* Set these to your Wifi credentials. */ | |
const char* ssid = "SSID-OF-YOUR-HOTSPOT"; // SSID of your Router OR mobile hotspot | |
const char* password = "PASSWORD OF YOUR HOTSPOT"; // PASSWORD of your Router or Mobile hotspot see below example | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(115200); // to enable Serial Commmunication with connected esp8266 board | |
delay(500); | |
WiFi.mode(WIFI_STA); // changing ESP9266 wifi mode to STATION | |
Serial.println(""); | |
Serial.println(""); | |
Serial.println("connecting to :"); | |
Serial.println(ssid); | |
Serial.println(WiFi.hostname()); | |
WiFi.begin(ssid, password); // to tell ESP8266 Where to connect and trying to connect | |
while (WiFi.status() != WL_CONNECTED) { // While loop for checking Internet Connected or not | |
delay(500); | |
Serial.print("."); | |
} | |
Serial.println(""); | |
Serial.println("WiFi connected"); | |
Serial.println("IP address: "); | |
Serial.println(WiFi.localIP()); // successful Connection of ESP8266, | |
// printing Local IP given by your Router or Mobile Hotspot, | |
// Esp8266 connect at this IP | |
Serial.println(""); | |
Serial.println("Download and Open Advanced IP scanner application given in description to see board is connected (you can see Espressif inc iin manufracturer"); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment