2
0

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 1 year has passed since last update.

ESP32のホスト名を設定する

Posted at

現在ESP32を使用して製品開発をしているが、
ESP32をネットワークに接続する際、
ホスト名がデフォルトでは「arduino-esp32」になってしまっている。

しかし、今回の製品はESP32を複数台同じネットワークに接続するので
それではホスト名が同じになってしまっているので、端末の識別が難しくなる。

そこで今回は海外サイトをほじくってホスト名の設定方法を
調べました。

設定方法

#include <WiFi.h>

const char* ssid = "****";
const char* password = "****";
String hostname = "hostname";

void initWiFi() {
  WiFi.mode(WIFI_STA);
  WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
  WiFi.setHostname(hostname.c_str());//ここでホスト名を設定します

  WiFi.begin(ssid, password);
  Serial.print("Connecting to WiFi ..");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print('.');
    delay(1000);
  }
  Serial.println(WiFi.localIP());
}

void setup() {
  Serial.begin(115200);
  initWiFi();
  Serial.print("RRSI: ");
  Serial.println(WiFi.RSSI());
}

void loop() {
  // put your main code here, to run repeatedly:
}

現在監視カメラにデジタル出力をできる機能をつけた製品を
開発しています。(WiFiによりネットワーク接続)
スマホやPCから操作が可能です。
気になる方はお気軽にご連絡下さい。

2
0
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?