ESP32C3 power consumption

Hi!
I am currently working on a BLE based Buzzer (emulating a 1 key keyboard). It can be configured and updated by connecting to a WiFi on demand.
When checking power consumption of my XIAO ESP32C3 board, I encountered a strage behavior.
Runing my Arduino sketch that implements a BLE service causes a current of about 80mA. When going to deep sleep, the consumption drops to around 40µA. So far so good.
What surprised me is the fact, that connecting to a WiFi network along with running the BLE service causes the current to drop to around 40-45mA. That’s a reduction to approximatly 50% that could double battery life!
What is going on in the module, that both WiFi and BLE will draw less current than BLE only?
I tried to actively switch off WiFi (to prevent an idle WiFi module from consuming power) but didn’t get the expected result.
During Setup the consuption is around 80mA but drops as soon as the WiFi connection succeeded.
Is there a way to reduce power consumption without connecting to a WiFi?

TIA,
Helge

Hi there,
All seems normal for the BLE , all default setting for Transmit power , advertising interval , etc.Is the USB connected?
What does the code look like?
Post up more info.
HTH
GL :slight_smile: PJ

Thanks for the quick reply.
I had to leave on an unexpected business trip and don’t have access to the sources right now.
I used settings fron Arduino code samples. The effect can be measured only when disconnected from USB because the device won’t draw power from the battery when connected. I didn’t measure consumption via USB yet.
I was just wondering, why an unused or idle WiFi draws more power than a connected WiFi.
BR, Helge.

Hi there,
Ok , well we are here all week :grinning: :v:
Well with out seeing the code in Question It may Active scanning or configured to be an AP.
All kinds of possibilities. Low power consumption is NOT and automatic thing.
HTH
GL :slight_smile: PJ
:v:

Hi,

I tried several settings. The first was just creating the WiFi instance but leaving it without further initialization.
Then I tried to configure as AP and another try using the mode that should switch off all WiFi activity. The only effect on power consumption was acting as client and connecting to an existing WiFi.
I will present code samples when I am back home.

BR,
Helge

1 Like

Back to my desk again!
Here is the code I use in Setup() to configure a WiFi connection. Depending on an IO pin status stored in enableWiFi, I enable WiFi. In normal operation, only BLE is used (bleKeyboard). For configuration, WiFi is added using a configured network. If this isn’t available, the device should set up a private acccess point to allow configuration.
Normal operation using BLE only works fine.
Configuration via WiFi works too, when I set the specific IO pin. Still have some difficulties to detect the missing network connection and to decide for an access point (but that’s another topic).
What I don’t understand is, that WiFi + BLE draws less current than BLE alone.
In this scenario I don’t have USB connected to measure current drawn from the battery.

  if (enableWiFi) {
    WiFi.mode(WIFI_STA);
    WiFi.disconnect();
    delay(100);
    int numNetworks = WiFi.scanNetworks();
    int idxNetwork = 0;
    while (idxNetwork < numNetworks) {
      if (WiFi.SSID(idxNetwork) == conf.ssid) {
        // we found the configured WiFi, try to connect
        Serial.println("WiFi found");
        break;
      }
      idxNetwork++;
    }
    WiFi.scanDelete();
    Serial.print("host name: ");
    Serial.println(hostName);
    Serial.printf("idx = %d, num = %d\n", idxNetwork, numNetworks);

    if (idxNetwork < numNetworks) {
      // connect to the configured WiFi
      WiFi.begin(conf.ssid.c_str(), conf.password.c_str());
      // Wait for connection
      Serial.printf("Connecting to %s...\n", conf.ssid.c_str());
      uint8_t idx = 0;
      while (WiFi.status() != WL_CONNECTED && idx < 10) {
        delay(500);
        idx++;
        Serial.print(".");
      }
      if (WiFi.status() == WL_CONNECTED) {
        Serial.println("");
        Serial.print("Connected to ");
        Serial.println(conf.ssid);
        Serial.print("IP address: ");
        Serial.println(WiFi.localIP());
        Serial.print("ESP Board MAC Address:  ");
        Serial.println(WiFi.macAddress());
        Serial.print("Host name: ");
        Serial.println(hostName);
        server = new WebServer(80);
        isAccessPoint = false;
      } else {
        Serial.println("no WiFi!");
        enableWiFi = false;
      }
    } else {
      // configure an access point
      Serial.println("");
      Serial.print("Access Point ");
      Serial.println(hostName);
      WiFi.mode(WIFI_AP_STA);
      if (!WiFi.softAP(hostName)) {
        Serial.println("failed");
        while (1) delay(500);
      }
      Serial.print("IP address: ");
      Serial.println(WiFi.softAPIP());
      Serial.print("ESP Board MAC Address:  ");
      Serial.println(WiFi.macAddress());
      Serial.print("Host name: ");
      Serial.println(hostName);
      server = new WebServer(WiFi.softAPIP(), 80);
      isAccessPoint = true;
    }
    if (MDNS.begin(hostName)) {
      Serial.println("MDNS responder started");
    }
    server->on("/", handleRoot);
	// ... more URLs
    server->begin();
    Serial.println("HTTP server started");
  } else {
    Serial.println("WiFi off");
    WiFi.disconnect(true);
    WiFi.mode(WIFI_OFF);
  }
  bleKeyboard.begin();
  Serial.println("bleKeyboard begin");
  esp_deep_sleep_enable_gpio_wakeup(BIT(D0), ESP_GPIO_WAKEUP_GPIO_LOW);

BR, Helge

The answer is Here , read the whole thing so advertised lows are suspect.
HTH

GL :slight_smile: PJ :v: