Use the same circuit found in the previous lecture. For real hardware, copy in the following code:

#include <ESP8266WiFi.h>

// WiFi config
const char ssid[] = YOUR NETWORK'S SSID";
const char password[] = "YOUR NETWORK'S PASSWORD";

void setup() {

  // Initialize Serial
  Serial.begin(9600);
  delay(100);

  // Connect to WiFi
  Serial.print("Connecting to ");
  Serial.print(ssid);
  WiFi.begin(ssid, password);
  while ( WiFi.status() != WL_CONNECTED ) {
    delay(500);
    Serial.print(".");
  }
  Serial.println();

  // Show that we are connected
  Serial.println("Connected!");

  // Print IP address
  Serial.println(WiFi.localIP());
}

void loop() {
  // put your main code here, to run repeatedly:

}

If you are using the simulator, copy in the following code:

#include "SoftwareSerial.h"

// WiFi config
String ssid     = "Simulator Wifi";
String password = "";

SoftwareSerial soft(8, 9); // RX, TX

void setup() {
  
  // Initialize serial connections
  Serial.begin(115200);
  soft.begin(9600);
  
  // Talk to ESP8266
  soft.println("Init ESP8266...");
  Serial.println("AT");
  delay(10);
  if ( Serial.find("OK") == 0 ) {
    soft.println("ESP8266 not found");
    while(1);
  }
  
  // Connect to WiFi
  soft.println("Connecting to WiFi...");
  Serial.println("AT+CWJAP=\"" + ssid + "\",\"" + password + "\"");
  delay(10);
  if ( Serial.find("OK") == 0 ) {
    soft.println("Could not connect to WiFi");
    while(1);
  } else {
    soft.println("Connected!");
  }
  
  // Print IP address
  soft.println("Getting IP...");
  Serial.println("AT+CIFSR");
  delay(10);
  soft.print(Serial.readString());
}

void loop() {
  
}