0Pricing
Arduino & IoT Academy · Lesson

Connect to WiFi in Station Mode

Join your network and print the IP address.

Connect to WiFi in Station Mode is a free Arduino & IoT Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Arduino & IoT Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What Station Mode Is

When your board joins an existing network like a phone joins WiFi, that is Station mode. Your router is the host; the ESP is a guest. 📶

Include the Library

Everything starts by including the WiFi library. That one line gives you connect, status, and address functions.

#include <WiFi.h>

Store Your Credentials

Save your network name and password in const char variables. Keeping them near the top makes them easy to update later.

const char* ssid = "MyNetwork";
const char* password = "secret123";

SSID Is the Network Name

The SSID is simply the WiFi name you tap on your phone. It must match exactly, including capital letters and spaces.

Set the Mode

Tell the chip to act as a client with WiFi.mode(). Setting station mode keeps it from accidentally becoming its own hotspot.

WiFi.mode(WIFI_STA);

Start the Connection

Kick things off with WiFi.begin(), passing your ssid and password. This starts the handshake with the router.

WiFi.begin(ssid, password);

Connecting Takes Time

Joining is not instant. You wait in a loop and check WiFi.status() until it reports WL_CONNECTED.

while (WiFi.status() != WL_CONNECTED) {
  delay(500);
  Serial.print(".");
}

Show Progress Dots

Printing a dot each loop gives friendly feedback. When the dots stop, your board has successfully joined the network.

Grab Your IP Address

Once connected, the router hands your board an IP address. Read it with WiFi.localIP() so you know how to reach the device.

Serial.println(WiFi.localIP());

The IP Identifies the Device

That IP address is your board's home on the network. You type it in a browser later to open pages your ESP serves.

When It Will Not Connect

Stuck on dots forever? Double-check the password and SSID, and remember ESP boards only join 2.4 GHz networks, not 5 GHz.

Quick Check

After WiFi.begin runs, how do you confirm the board actually joined the network?

Recap

You joined a router in Station mode: include WiFi, set credentials, call begin, wait for WL_CONNECTED, then print your IP. 🎉

Frequently asked questions

Is the “Connect to WiFi in Station Mode” lesson free?

Yes — the full text of “Connect to WiFi in Station Mode” is free to read here on the web, and the Arduino & IoT Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Arduino & IoT Academy course, upgrade to CoddyKit PRO.

What will I learn in “Connect to WiFi in Station Mode”?

Join your network and print the IP address. You practise Arduino & IoT Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Arduino & IoT Academy?

No prior experience is required. Arduino & IoT Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Connect to WiFi in Station Mode” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Arduino & IoT Academy lesson?

Yes. Every Arduino & IoT Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Why ESP32 & ESP8266 for IoT
  2. Add ESP Boards to the IDE
  3. Connect to WiFi in Station Mode
  4. Run an Access Point Setup Page
← Back to Arduino & IoT Academy