14
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ESP32をWiFiにつなげる

Posted at

ESP32をWiFiに繋げたので、スケッチを書いておく

ESP32-DevKitC 及び HiLetgo ESP-32s NodeMCU
ArduinoIDE 1.8.5

Arduino WiFi Library
https://www.arduino.cc/en/Reference/WiFi

WiFi.ino

#include <WiFi.h>

// 接続先のSSIDとパスワード
const char ssid[] = "########";
const char passwd[] = "########";

void setup() {
    Serial.begin(115200);

    // Connect WiFi
    connectWiFi();
}
void loop() {
    // Reconnect
    if ( WiFi.status() == W_DISCONNECTED ) {
        connectWiFi();
    }
}

/**
 * Connect WiFi
 */
void connectWiFi()
{
    WiFi.begin(ssid, passwd);
    Serial.print("WiFi connecting...");
    while(WiFi.status() != WL_CONNECTED) {
        Serial.print(".");
        delay(100);
    }
    Serial.print(" connected. ");
    Serial.println(WiFi.localIP());
}
14
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?