8000 ESP32-C3 Mini Development Board not able to connect to WiFi · Issue #780 · HomeSpan/HomeSpan · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
ESP32-C3 Mini Development Board not able to connect to WiFi #780
Closed
@fbernaly

Description

@fbernaly

First, thank you very much for this plugin. Now I can create my own Homekit compatible devices without the the of Homebridge. It is very nice how this plugin lets me to use ESP32 and connect directly to Homekit without the of a 3rd party bridge.

I am working on this home project to control my son's beside led strip light with ESP32.

I prototyped it using ESP32-WROOM-32, but I do not need that many GPIO and want to use a smaller ESP32 and I went with the ESP32-C3 Mini Development Board (aka ESP32-C3-Zero) by waveshare. It is a very tiny dev board that suit my needs.

However, I found that there is an issue with the ESP32-C3-Zero, it does not connect to WiFi, this is what I get in the logs:

11:35:18.383 -> Accessory configuration has changed.  Updating configuration number to 2
11:35:18.383 -> 
11:35:18.383 -> esp32-lighting is READY!
11:35:18.383 -> 
11:35:18.383 -> Trying to connect to SSID.  Waiting 1 sec...
11:35:19.415 -> Trying to connect to SSID.  Waiting 2 sec...
11:35:19.415 -> E (4395) wifi:sta is connecting, return error
11:35:21.447 -> Trying to connect to SSID.  Waiting 4 sec...
11:35:25.434 -> Trying to connect to SSID.  Waiting 8 sec...
11:35:33.419 -> Trying to connect to NETGEAR54.  Waiting 16 sec...
11:35:49.426 -> 
11:35:49.426 -> *** Can't connect to SSID.  You may type 'W <return>' to re-configure WiFi, or 'X <return>' to erase WiFi credentials.  Will try connecting again in 60 seconds.
11:35:49.426 -> 

It connects only if I add this line after WiFi.begin():

WiFi.begin(ssid, password);
WiFi.setTxPower(WIFI_POWER_8_5dBm); // <- need to add this line

I found that workaround in this thread.

Since HomeSpan sets the WiFi credentials using CLI. I have found no way to set WiFi.setTxPower other than with this workaround: call both WiFi.begin and WiFi.setTxPower in my setup() like this:

#define LED_PIN 1
#define PUSH_BUTTON_PIN 2

const char* ssid = "<YOUR_SSID>";
const char* password = "<YOUR_PASSWORD>";

void connectToWifi() {
  WiFi.begin(ssid, password);
  WiFi.setTxPower(WIFI_POWER_8_5dBm); // <-- This is the important line
  Serial.print("Connecting to WiFi");
  int i = 0;
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    digitalWrite(LED_PIN, (i++) % 2);
    delay(50);
  }
  digitalWrite(LED_PIN, LOW);
  Serial.print("\nConnected to WiFi network with IP Address: ");
  Serial.println(WiFi.localIP());
}

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

  connectToWifi();

  ... // the rest of my stuff
}

void loop() {
  homeSpan.poll();  // run HomeSpan!
}

When I do this it connects to the WiFi. But I need to set WiFi credential in both CLI and inside the setup() method. Is there a more elegant way to tackle this? How can I edit the CLI command to set WiFi.setTxPower(WIFI_POWER_8_5dBm) as well?

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature available in devThis feature request is now available in dev for user testing

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0