3
3

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 3 years have passed since last update.

M5StickC(ESP32)にいちばん強いWifiに接続してほしい(WiFiMulti)

Posted at

WiFiMultiというクラスがありましたとさ。

wifimulti.cpp

#include <Arduino.h>
#include <M5StickC.h>
#include <WiFi.h>
#include <WiFiMulti.h>

WiFiMulti wifiMulti;

#include "secret.h"

void setup() {
  M5.begin();
  wifiMulti.addAP(SSID1, PASSPHRASE1);
  wifiMulti.addAP(SSID2, PASSPHRASE2);
}

void loop() {
  M5.Lcd.setRotation(1);
  M5.Lcd.fillScreen(BLACK);
  M5.Lcd.setCursor(0, 0);
  M5.Lcd.setTextColor(WHITE);
  M5.Lcd.setTextSize(1);

  printf("WiFiMulti connecting...\n");
  M5.Lcd.printf("WiFiMulti connecting...\n");

  if(wifiMulti.run() == WL_CONNECTED) {
    printf("CONNECTED: ssid=%s localIP=%s\n", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());
    M5.Lcd.printf("ssid=%s\n", WiFi.SSID().c_str());
    M5.Lcd.printf("localIP=%s\n", WiFi.localIP().toString().c_str());
  }else{
    printf("failed\n");
    M5.Lcd.printf("failed\n");
  }
  WiFi.disconnect();
  printf("disconnected.\n");
  M5.Lcd.printf("disconnected.\n");
  delay(1000);
}
3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?