0Pricing
Arduino & IoT Academy · บทเรียน

เชื่อมต่อ WiFi ในโหมดสถานี

เข้าร่วมเครือข่ายและแสดงที่อยู่ IP

เชื่อมต่อ WiFi ในโหมดสถานี เป็นบทเรียน Arduino & IoT Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Arduino & IoT Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

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. 🎉

คำถามที่พบบ่อย

บทเรียน “เชื่อมต่อ WiFi ในโหมดสถานี” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “เชื่อมต่อ WiFi ในโหมดสถานี” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Arduino & IoT Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “เชื่อมต่อ WiFi ในโหมดสถานี”

เข้าร่วมเครือข่ายและแสดงที่อยู่ IP คุณปฏิบัติ Arduino & IoT Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Arduino & IoT Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Arduino & IoT Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน

บทเรียน “เชื่อมต่อ WiFi ในโหมดสถานี” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Arduino & IoT Academy นี้ได้ไหม

ได้ บทเรียน Arduino & IoT Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. ทำไม ESP32 และ ESP8266 จึงเหมาะกับ IoT
  2. เพิ่มบอร์ด ESP ใน IDE
  3. เชื่อมต่อ WiFi ในโหมดสถานี
  4. สร้างหน้าตั้งค่าจุดเข้าถึง
← กลับไปที่ Arduino & IoT Academy