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

ESP32S3でWiFiが繋がらない時の対処法

Last updated at Posted at 2025-12-23

困ったこと

XIAO ESP32-S3でWiFiを使ってラジコンを作ったのですが、なかなかWiFiに繋がらないことがありました。ESP32-WROOM-32Eではこの問題が起きなかったのでこのマイコン特有の問題であると考えました。

原因

調べてみるとこちらのページを読んで原因が分かりました。
https://intellectualcuriosity.hatenablog.com/entry/2024/01/30/123336
どうやらESP32-S3はWiFiの送信出力を抑えないと繋がらないものがあるようです。
また、送信出力はesp_wifi.h内の
esp_err_t esp_wifi_set_max_tx_power(int8_t power);
という関数で設定されていますが、コメント部分に次のように書かれていました。

/**
  * @brief     Set maximum transmitting power after WiFi start.
  *
  * @attention 1. Maximum power before wifi startup is limited by PHY init data bin.
  * @attention 2. The value set by this API will be mapped to the max_tx_power of the structure wifi_country_t variable.
  * @attention 3. Mapping Table {Power, max_tx_power} = {{8,   2}, {20,  5}, {28,  7}, {34,  8}, {44, 11},
  *                                                      {52, 13}, {56, 14}, {60, 15}, {66, 16}, {72, 18}, {80, 20}}.
  * @attention 4. Param power unit is 0.25dBm, range is [8, 84] corresponding to 2dBm - 20dBm.
  * @attention 5. Relationship between set value and actual value. As follows: {set value range, actual value} = {{[8,  19],8}, {[20, 27],20}, {[28, 33],28}, {[34, 43],34}, {[44, 51],44}, {[52, 55],52}, {[56, 59],56}, {[60, 65],60}, {[66, 71],66}, {[72, 79],72}, {[80, 84],80}}.
  *
  * @param     power  Maximum WiFi transmitting power.
  *
  * @return
  *    - ESP_OK: succeed
  *    - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
  *    - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
  *    - ESP_ERR_WIFI_ARG: invalid argument, e.g. parameter is out of range
  */
esp_err_t esp_wifi_set_max_tx_power(int8_t power);

attention 2を見ると「WiFiの送信出力がwifi_country_tで定義される変数によって変換される」と書いてあります。つまり使用する国によって送信出力が制限されているのではないかと考えました。おそらく国の定義を変えて使えたとしても電波法に触れる可能性があるため、今回はこの定義を変えることはしませんでした。

対応策

WiFiの送信出力を抑えることで通信できるようになりました。
今までは送信出力は78で使用していましたが、今回のESP32S3では値を70まで下げたら正常に通信ができました。

WiFi.setTxPower((wifi_power_t)70);

免責事項(決まり文句)

参考にしていただくのは嬉しいですが、その結果生じた損害等の責任は負えません。
自己責任でお願いします。

最後に

もし内容に誤りがあったり、もっと良い方法等があればX(@_electro_master)までご連絡をお願いします。

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