1/25
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
What does this code do?
Turns an Arduino with an ESP8266 WiFi shield into a simple web server that displays "Hello World!"
Includes the main library needed to control the ESP8266 WiFi module.
Includes the library that allows the Arduino to create a "virtual" serial port on digital pins.
SoftwareSerial softserial(4, 5); What does this line do?
Creates a new software serial port, telling the Arduino that pin 4 is for Receiving (RX) and pin 5 is for Transmitting (TX).
char ssid[] = "…"; What is this variable for?
Stores the name (SSID) of your WiFi network.
char pass[] = "…"; What is this variable for?
Stores the password for your WiFi network.
WiFiEspServer server(80); What does this line do?
Creates a web server object that will listen on port 80.
Port 80 What is special about Port 80?
It is the standard, default port for HTTP (web) traffic.
setup() What is the purpose of the setup() function?
It's a function that runs only once when the Arduino first powers on to initialize everything.
Serial.begin(9600); What does this command do?
Initializes the main serial port for communication with the computer's Serial Monitor at 9600 baud.
softserial.begin(9600); What does this command do?
Initializes the software serial port for communication with the WiFi shield at 9600 baud.
WiFi.init(&softserial); What does this command do?
Tells the WiFiEsp library to use the softserial port to talk to the WiFi shield.
WiFi.begin(ssid, pass); What does this command do?
Attempts to connect the Arduino to the WiFi network using the stored SSID and password.
server.begin(); What does this command do?
Starts the web server, telling it to begin listening for incoming connections.
loop() What is the purpose of the loop() function?
It's a function that runs over and over forever after setup() is complete.
WiFiEspClient client = server.available(); What does server.available() do?
Checks if a new client (like a web browser) has tried to connect. If yes, it returns a client object.
if (client) What does this line check?
Checks if a new client has successfully connected to the server.
client.read() What does this function do?
Reads one character of data (part of the HTTP request) sent from the web browser.
HTTP/1.1 200 OK What is this?
A standard HTTP response header sent from the server to the browser, meaning "the request was successful."
Content-Type: text/html What does this HTTP header tell the browser?
That the data being sent next is an HTML webpage.
Refresh: 20 What does this HTTP header tell the browser?
To automatically reload the page every 20 seconds.
client.print() What is this command used for in the loop?
To send data (the HTML webpage) back to the client's web browser.
++reqCount What does this expression do?
Increments the reqCount variable by one and then uses its new value.
client.stop() What does this command do?
Closes the connection to the web client after the full response has been sent.
printWifiStatus() What is the purpose of this custom function?
To print the Arduino's network name (SSID) and its local IP address to the Serial Monitor.
WiFi.localIP() What does this function return?
The IP address that the WiFi network assigned to the Arduino (e.g., 192.168.1.120).