Deep-sleep: current drained

Hi, testing my project that should even use a tamper, with a pull-up circuit, I discover that my D1 mini (usb powered, but also if supplied with 5V pin) drain current for pin in deep-sleep mode too :astonished:.

So I decided to measure whole current drained. My D1 mini drain 72mA when on (right) and 3.2mA when turned in deep-sleep mode from a switch in Home Assistant (too much, should be 0.17mA).

switch:
  # Deep sleep endless
  - platform: shutdown
    name: "DS endless"

I removed all from pin(s), and tested with just pin 5V and G (power supply) and I simplified code:

esphome:
  name: out-board

esp8266:
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "..."

ota:
  password: "..."

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "..."
    password: "..."

captive_portal:

switch:
  # Deep sleep (endless)
  - platform: shutdown
    name: "DS endless"

but still drain 2.8mA (should be 0.17mA) :exploding_head:

Can you help me to solve this problem?
Thank you

With about 3mA drained my project canā€™t work because I have to use battery.

Probably because you arenā€™t in the sleep mode?

Where is your deep.sleep component?

I used shutdown because I want that Home Assistant put to deep sleep the board and even more because it will be awakened by RST pin linked to ground thanks to another circuit.

Is not enought shutdown switch platform?
Is it needed deep_sleep component too? How could I configure it (run_duration and sleep_duration are unknown)?

OK, new component that I had not seen beforeā€¦

Back to the labā€¦

Where do you get this figure?

For example:
here
and here

However, as I wrote, itā€™s strange that pin (example tamper with pull-up circuit) drain current during deep-sleep.

Interesting, thanks.

Can you give your circuit diagram and how you are measuring?

Simply as this:

image

I removed pull-up circuit in last test, but was as shown here, with multimeter on switch.

How can I reduce drain? Is deep-sleep working?

OK, I duplicated your setup and can verify the ESP is sleeping and the board current is 3.22 mA.
Which I would expect because even if the processor is ā€œshut downā€, none of the other chips on the Wemos D1 Mini are. The CH340 and the Flash memory are still connected to the 3V3 line, so that is where much of the 3.22mA is going.

Which is probably why the D1 mini is a poor candidate for a battery operated device.
Is there any reason you couldnā€™t use an ESP8266-01?
A Zigbee switch or button is far superior to the ESP boards for low battery drain. What is it you are trying to do?

And thanks for alerting me to the Shutdown Switch platform. That could come in handy.

@stevemann the pages @Giove8 pointed to quoted .17mA for the whole d1 mini in deep sleep.

@Giove8 there are a number of versions of the d1 mini, I donā€™'t know the differences. Plus there are numerous cheap knockoffs out there. Many are crap.

He may be looking at the ESP8266 chip itself where the default sleep mode (modem-sleep) will be about 17mA:

esp8266_sleep_options

I have to question the docs here because the deep_sleep component has a sleep_duration configuration parameter, but in deep sleep the ESP clock is off. So, how does the ESP know when to wake?

BS. I buy my Miniā€™s from the most convenient and/or the cheapest supplier, usually 5 at a time because they are so cheap. I have NEVER had one DOA out of the static envelope.

Thanks to you @stevemann!
In the next days Iā€™ll try again, maybe also with deep_sleep componentā€¦ because however itā€™s not normal that D pin(s) still active on deep sleep mode.

I read that MQTT could be better than API for sleep mode, but I donā€™t believe that could work (I never installed MQTT on Home Assistant, so I canā€™t try now).

And if Iā€™ll have a D1 mini v3 o v4 Iā€™ll test thatā€¦

@stevemann I donā€™t know ESP8266-01, I should checkā€¦ I didnā€™t find zigbee switch or button with low dimensions, low drain that can drive a relay or even npnā€¦ If you could suggest something Iā€™ll appriciate appreciate it

RST pin close to GND for less than a second

What are you trying to control?

No, the component parameters include timing:

# Example configuration entry
deep_sleep:
  run_duration: 10s
  sleep_duration: 10min

If the ESP clock is off in deep-sleep, how does it know how long to run and how long to sleep?
At the end of the sleep_duration, the ESP pulls GPIO16 low. And GPIO16 must be connected to RST.
So, the ESP clock is running, thus it canā€™t be in deep-sleep mode, but in the default modem-sleep mode.

A 5V relay with 40mA will be perfect (even 3V relay will be ok), relay will drive a step-up voltage regulator that manage an important load. But also drive a simple npn, as I tested with D1 mini will be fineā€¦

I am trying to understand why the Mini has to be run from a battery.

Honestly I donā€™t know how it works :smiley: but I awake it in this way (RST to GND)ā€¦ However you could find interesting this

Because it will not stay at home, but outside and I canā€™t give energy with cable (all the system is power with batteryā€¦ but the important load for few minutes drain less that D1 mini, if drain 3mA for few weaks) :pensive: