สร้างหน้าตั้งค่าจุดเข้าถึง
ให้ผู้ใช้ป้อนข้อมูลเข้าสู่ระบบ WiFi จากโทรศัพท์
สร้างหน้าตั้งค่าจุดเข้าถึง เป็นบทเรียน Arduino & IoT Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Arduino & IoT Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
The Chicken-and-Egg Problem
How does a device with no screen learn your WiFi password? You cannot hardcode it for every user. Access Point mode solves this. 🥚
The Board Becomes the Host
In Access Point mode, the ESP creates its own WiFi network instead of joining one. Your phone connects directly to the board.
Set AP Mode
Switch roles with WiFi.mode() set to access point. Now the chip broadcasts a network rather than searching for one.
WiFi.mode(WIFI_AP);Name Your Hotspot
Create the network with WiFi.softAP(), giving it a name your users will recognize, like SmartSensor-Setup.
WiFi.softAP("SmartSensor-Setup");An Optional Password
You can add a password to softAP so only trusted people connect. Leave it open only for quick, local testing.
WiFi.softAP("SmartSensor-Setup", "config1234");The Board Gets an IP
As the host, your ESP picks its own IP address, often 192.168.4.1. Users type that into a browser to reach the page.
Serial.println(WiFi.softAPIP());Serve a Web Page
A small built-in WebServer hands out an HTML form. That form is where the user types their home WiFi details.
#include <WebServer.h>
WebServer server(80);Define a Route
Tell the server what to show at the root path using server.on(). This links the address slash to your setup form.
server.on("/", handleRoot);Keep It Listening
Inside loop() you call server.handleClient() on every pass. This is what answers each visitor's request promptly.
void loop() {
server.handleClient();
}Capture and Save
When the user submits, you read the typed credentials and store them so the device can join their network next boot.
This Is a Captive Portal
That self-hosted setup screen is called a captive portal. It is exactly how smart plugs and bulbs onboard onto your WiFi.
Quick Check
What is the main reason a device runs its own Access Point at first boot?
Recap
You hosted a setup hotspot: set AP mode, called softAP, served a form on a WebServer, and captured the user's WiFi details. 🎉
คำถามที่พบบ่อย
บทเรียน “สร้างหน้าตั้งค่าจุดเข้าถึง” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “สร้างหน้าตั้งค่าจุดเข้าถึง” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Arduino & IoT Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “สร้างหน้าตั้งค่าจุดเข้าถึง”
ให้ผู้ใช้ป้อนข้อมูลเข้าสู่ระบบ WiFi จากโทรศัพท์ คุณปฏิบัติ Arduino & IoT Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Arduino & IoT Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Arduino & IoT Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “สร้างหน้าตั้งค่าจุดเข้าถึง” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Arduino & IoT Academy นี้ได้ไหม
ได้ บทเรียน Arduino & IoT Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- ทำไม ESP32 และ ESP8266 จึงเหมาะกับ IoT
- เพิ่มบอร์ด ESP ใน IDE
- เชื่อมต่อ WiFi ในโหมดสถานี
- สร้างหน้าตั้งค่าจุดเข้าถึง