アクセスポイントの設定ページを動かす
スマートフォンからWiFi認証情報を入力できるようにします。
「アクセスポイントの設定ページを動かす」はCoddyKit上の無料Arduino & IoT Academyレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これは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. 🎉
よくある質問
「アクセスポイントの設定ページを動かす」レッスンは無料ですか?
はい。「アクセスポイントの設定ページを動かす」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Arduino & IoT Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Arduino & IoT Academyコースには全4レッスンが含まれています。
「アクセスポイントの設定ページを動かす」で何を学びますか?
スマートフォンからWiFi認証情報を入力できるようにします。 ブラウザで直接実行するハンズオンコードでArduino & IoT Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Arduino & IoT Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのArduino & IoT Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「アクセスポイントの設定ページを動かす」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このArduino & IoT Academyレッスンでコードを書いて実行できますか?
はい。すべてのArduino & IoT Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- IoTにESP32とESP8266を使う理由
- IDEにESPボードを追加する
- ステーションモードでWiFiに接続する
- アクセスポイントの設定ページを動かす