Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with ESP12f without WiFi on 50mA power source #2111

Closed
tuxedo0801 opened this issue Jun 7, 2016 · 16 comments
Closed

Problems with ESP12f without WiFi on 50mA power source #2111

tuxedo0801 opened this issue Jun 7, 2016 · 16 comments

Comments

@tuxedo0801
Copy link
Contributor

tuxedo0801 commented Jun 7, 2016

Basic Infos

Hardware

Hardware: ESP-12F
Core Version: 2.2.0

Description

I want to drive my ESP12F module from a 50mA@3.3V source. For this application I don't need WiFi at all. So I disabled it.
If I measure the current consumption with my multimeter, I get about 14mA@3.3V. That would be okay for my power source.
But as soon as I connect the ESP to the meant power source, the 3.3V line drops to 1.8V and I can measure a current consumption of about 30..35mA. The blue LED on the ESP12F starts to flicker continuously.
My current theory is:
The ESP8266 has a too high starup current consumption my power source cannot handle. I added an 100µF capacitor, but this does not solve the issue.
I don't have a scope to measure the exact startup current.

Question is:

  • Is my code okay (wrt. disabling WiFi completely)? Of course the consumtion I can measure is just about 14mA, but maybe there is a "faster way" of disabling it to reduce startup current consumption?!
  • Does anybody know about the startup power consumption without wifi or can do a measurement with a scope?!
  • Are there known issues with this scenario (no wifi, low current power source)?

Settings in IDE

Module: Generic ESP8266 Module
Flash Size: 4MB
CPU Frequency: 80Mhz
Flash Mode: qio
Flash Frequency: 40Mhz
Upload Using: SERIAL
Reset Method: ck

Sketch

#include <ESP8266WiFi.h>

void setup() {
    // turn off wifi completely   
    WiFi.disconnect(); 
    WiFi.mode(WIFI_OFF);
    WiFi.forceSleepBegin();
    delay(10);

    Serial.begin(19200);  

}

void loop() {

  Serial.println("HIGH");

  delay(3000);

  Serial.println("LOW");

  delay(3000);

} 
@igrr
Copy link
Member

igrr commented Jun 7, 2016

Can you try adding RF_MODE(RF_DISABLED); line between include and void setup?
After that calling WiFi.xxx functions should not be needed.
Note that this requires a pretty recent version, like staging 2.3.0-rc1 or git version.

@tuxedo0801
Copy link
Contributor Author

Thanks.I will test it this evening.

But I'm still interested in a scope-screenshot showing the current consumption on startup. So If someone can help ...

@igrr
Copy link
Member

igrr commented Jun 7, 2016

Bummer, RF_MODE(RF_DISABLED); works only after deep sleep wakeup, not after normal power-up.
I've got some scope pics, will post a bit later.

@igrr
Copy link
Member

igrr commented Jun 7, 2016

Some scope pics taken using a 2.5 Ohm current shunt. Scale is therefore 80 mA / 200 mV.

Test 1: Your sketch. You can see that RF calibration is causing large current spikes (300mA peak)
tek00011

Test 2: Your sketch, and also disabling RF calibration

extern "C" {
#include <user_interface.h>
}

RF_PRE_INIT()
{
  system_phy_set_powerup_option(2);
}

// rest of the sketch

tek00016

Same trace, closeup of the remaining spike (approx 320mA, 0.8ms):
tek00015

Test 3: attempt to disable WiFi early. Added a hook to user_init in core_esp8266_main.c:

extern void early_init();

extern "C" void user_init(void) {
  // all the existing code
  early_init();
}

And move WiFi configuration from setup into this new function (inside the sketch):

void early_init() {
  WiFi.persistent(false);
  WiFi.mode(WIFI_OFF);
  WiFi.forceSleepBegin();
}

tek00017

Same trace, different vertical scale:
tek00018
The remaining spike is about 100mA, 0.8ms. Can probably be filtered out by a capacitor.

@krzychb
Copy link
Contributor

krzychb commented Jun 7, 2016

@igrr,
Do you mean one division on the screen = 40mA and max spikes = 80mA?

@igrr
Copy link
Member

igrr commented Jun 7, 2016

I have updated my previous comment with some numbers.
The mentioned hack with an extra hook in user_init can make its way into the core, i guess. Would be useful to turn off wifi depending on certain conditions.

@tuxedo0801
Copy link
Contributor Author

tuxedo0801 commented Jun 7, 2016

Thanks for the screenshots. I will test it and report back.

can make its way into the core, i guess

What does this mean? How would one disable wifi in future with this change?

[update]

Ah, now I got it. There might be a new "void early_init()" method which you can use in the sketch to do "very early things"..

@tuxedo0801
Copy link
Contributor Author

tuxedo0801 commented Jun 7, 2016

100µF capacitor and code changes as suggested in Test3 give me flickering blue led and console tells me repeatedly:

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

case 2 = reset pin
mode 3 = flash ...

is this normal if power source does not provide enough current?

same setup with mit current on power source boots as expected.

Will repear test with more µF ...

@tuxedo0801
Copy link
Contributor Author

tuxedo0801 commented Jun 7, 2016

200µF gives me on console:

ets Jan 8 2013,rst cause:1, boot mode:(3,6)

load 0x4010f000, len 1264, room 16

To compare: with optimal power supply (more than up to 2,5A instead of just 50mA max), I get:

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1264, room 16
tail 0
chksum 0x0f
csum 0x0f
~ld

@igrr
Copy link
Member

igrr commented Jun 8, 2016

Looks like you aren't reaching the point when ROM bootloader finishes reading second stage bootloader from flash. How much of a voltage drop does your power supply have at 50mA?

@tuxedo0801
Copy link
Contributor Author

tuxedo0801 commented Jun 8, 2016

It's not a "real" power supply.
The ESP12 is attached to a "KNX Transceiver" which is connected to the (wired) KNX home automation bus. The KNX transceiver IC (www.onsemi.com/pub_link/Collateral/NCN5120-D.PDF) is able to provide about 40..50mA at 3.3V (DC-DC converted bus power)
There is no spec/figure/graph showing the voltage drop over current consumption. The current estimated current limit is about 40mA, 50mA should be also possible. I can try to measure the voltage drop when applying a big enough resistor to simulate constant 50mA current consumption.

P.S. I just saw that Test3 might include changes from Test2... Sketch is changed accordingly, has to be tested this evening...

@tuxedo0801
Copy link
Contributor Author

Good news... with all your suggestes changes (test1+2+3) in addition to an 470µF capacitor on Vcc, ESP now now able to start with my luw current power source...

Thanks a lot.

@tuxedo0801
Copy link
Contributor Author

btw:

Would be great if we could add those code-changes to the next release?!

@igrr
Should I make a PR or do you add those changes yourself?

@igrr
Copy link
Member

igrr commented Jun 12, 2016

Awesome, glad that this worked for you.
Created #2133 to track changes necessary in the core.

@wb8wka
Copy link

wb8wka commented Jul 10, 2017

Is there a reason RF_MODE(RF_NO_CAL); would not be working? 2.3.0 with a Wemos D1 mini. All I can do is either turn the RF off or RF_CAL is on. with with the call to RF_NO_CAL

@dioguerra
Copy link

This reduction of power consumption doesn't seem to work on 2.4.0-rc2

using user_init()

d-a-v added a commit to d-a-v/Arduino that referenced this issue Nov 30, 2018
earlephilhower pushed a commit that referenced this issue Dec 4, 2018
* weak hook early_setup() #2111 #2133 #2136

* rename to early_init (more "c" vs early_setup which is more "c++arduino")

* example

* improve earlyWiFi example, slightly change AddrList interface, move WiFi sketches into WiFi examples

* fix CI

* fix local CI runner

* fix local CI runner

* rename early_init() to preinit()

* + static ESP8266WiFiClass::preinit_wifi_off()

* update early disable wifi example

* example update

* IPv6 example update

* Update ESP8266WiFiGeneric.h

camelCase for static method name

* Update ESP8266WiFiGeneric.cpp

camelCase for static method name

* Update EarlyDisableWiFi.ino

Expand comment, fix static method name

* Update core_esp8266_main.cpp

Expanded comment.

* Update core_esp8266_main.cpp

Expanded comment

* Update EarlyDisableWiFi.ino

Expanded comment
TD-er added a commit to letscontrolit/ESPEasy that referenced this issue Jan 15, 2019
See:
- esp8266/Arduino#2111
- https://github.com/esp8266/Arduino/pull/5395/files

Hopefully it will help for modules which have a hard time to connect to WiFi, which may be caused by weak power supply.
It will also not start unintended DHCP-client services which lead to strange issues when using static IP configuration.
Tests should reveal if it will also help to lessen the chaos which may happen now the 'May deal' is off, so please perform some tests and we'll see the coming days.
At least it will save some peak power at startup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants