Connettersi al WiFi in modalità Station
Si colleghi alla rete e stampi l'indirizzo IP.
Connettersi al WiFi in modalità Station è una lezione Arduino & IoT Academy gratuita su CoddyKit. Questa è la lezione 3 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Arduino & IoT Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Arduino & IoT Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
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. 🎉
Domande Frequenti
La lezione «Connettersi al WiFi in modalità Station» è gratuita?
Sì — il testo completo di «Connettersi al WiFi in modalità Station» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Arduino & IoT Academy, passa a CoddyKit PRO. Il corso Arduino & IoT Academy include 4 lezioni in totale.
Cosa imparerò in «Connettersi al WiFi in modalità Station»?
Si colleghi alla rete e stampi l'indirizzo IP. Eserciti Arduino & IoT Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Arduino & IoT Academy?
Non è richiesta alcuna esperienza precedente. Arduino & IoT Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 3 di 4.
Quanto tempo richiede la lezione «Connettersi al WiFi in modalità Station»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Arduino & IoT Academy?
Sì. Ogni lezione Arduino & IoT Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Perché ESP32 ed ESP8266 sono adatti all'IoT
- Aggiungere le schede ESP all'IDE
- Connettersi al WiFi in modalità Station
- Eseguire una pagina di configurazione Access Point