Engineer Jagat

IT & Engineering Stuff

How to connect ESP8266 to WiFi Network?

October 18, 2020
How to connect ESP8266 to WiFi Network?

ESP8266 is a low-cost WiFi Microchip. It is the most used WiFi microchip nowadays, popular among Network Programmer, Hobbyist and Tech Enthusiast.

In this post we are going to learn How to Connect ESP8266 to WiFi Network? And see the result blinking LED s after successful connection.

Let’s do it Step-by-Step

Step 1: Setup

Before start coding we have to setup Arduino IDE and ESP8266WiFi.h header file to our IDE.So if you are not installed or setup a header file download it from the official website https://www.arduino.cc/en/Main/Software

Step 2: Code

#include "ESP8266WiFi.h"

const char* ssid = "Hello World"; //Your SSID
const char* password = "password@1234"; //Your Password


void setup(void)
{ 
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(115200);
  // Connect to WiFi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) 
  {
     delay(1000);
     Serial.print("#");
  }
  
  Serial.println("");
  Serial.println("WiFi Connected");
  Serial.print("IP Address: ");
  Serial.print(WiFi.localIP());
}

void loop() 
{
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

Step 3: Output

Blink LED after successfully Network Connection

Share with Friends
Copyright © 2020-2021 Engineer Jagat All rights reserved. Developed by Ravindra Rana