Connecting To WiFi and LCD display

This is a variation on this sketch - it still just connects to your WiFi network but now displays the connection status on an LCD display connected to the I2C bus. You can download the new sketch here or just copy and paste from below. You need to know the I2C address of the LCD backpack - it's usually 0x27 or 0x3F - and change the sketch accordingly. The LCD consumes about 42mA at 5V and about 14mA at 3.3V.

The connections required from the LCD are:

You can use different digital pins for I2C but you'll need to change the symbol definitions for SCL and SDA in the sketch.

/*******************************************************************************
* es-connect-to-wifi-lcd V1.0 01-Aug-2018 JST Lawrence.                        *
*                                                                              *
* Purpose: connects to a wireless network and displays status.                 *
*                                                                              *
* Output: display connection progress and IP address once connected.           *
*                                                                              *
*******************************************************************************/

#include "ESP8266WiFi.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define SCL 0
#define SDA 2

const char* ssid="**********";    // Put your SSID here
const char* password="**********";  // Put your password here

// Define lcd - address, number of columns, number of rows
LiquidCrystal_I2C lcd(0x3F,20,4);

void setup(void)
{ 
  int OnOff,pos=0;

  OnOff=0;

  pinMode(2,OUTPUT);
  Wire.begin(SDA,SCL);  // GPIO numbers for SDA and SCL respectively
                        // SDA - GPIO2 - pin D4
                        // SCL - GPIO0 - pin D3
  lcd.init();
  lcd.backlight();
  lcd.clear();

// Connect to WiFi
  lcd.setCursor(0,0);
  lcd.print("Connecting to ");
  lcd.setCursor(0,1);
  lcd.print(ssid);
  WiFi.begin(ssid, password);

// Loop until we obtain a connection
  while (WiFi.status()!=WL_CONNECTED) 
  {
    digitalWrite(2,OnOff=1-OnOff);
    delay(250);
    digitalWrite(2,OnOff=1-OnOff);
    delay(250);
    lcd.setCursor(pos++,2);
    lcd.print(".");
  }

  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Connected to network");
  lcd.setCursor(0,2);
  lcd.print("IP=");
  lcd.setCursor(3,2);
  lcd.print(WiFi.localIP());
  
}

void loop() 
{
// Put your code here

}