But the deepsleep overall current 220 µA is a lot.
How long does your cell last? Whats the wake sleep cycles like for time?
5x what seed studio wiki gives. How you measure it?
I measure between the positive side of the battery and the 3.3 volt connection of the ESP.
How should I interpret that? Battery positive is not connected to 3.3V …
Forgot you have lifepo4 connected directly.
Is your current meter fine with low currents?
I don’t know the quality but it has a measuring range of 0-9999 µA and 0-99.99 mA and it is the Velleman DVM040.
Translation for the less technically advanced
who might read this thread …
The most common reason for using deep_sleep is to use less power and make the battery last longer. The previous few messages (and some other threads) are about squeezing the maximum battery life - not necessary, but once you have done the easy things this is well worth considering.
I’ve not got to measuring the actual consumption myself (yet) but have come across the comment that while the current (power consumption) of a chip is specified, the rest of the components on that board are generally not mentioned. Even the power/status LED on your ESP32 Development Board is drawing power, which could be orders of magnitude greater than the sleep current specified for the main chip. And that power is being consumed even while the processor is asleep.
I have seen suggestions of disconnecting the status LEDs by cutting the wiring on the circuit boads - but with my age, dexterity and soldering skills I’ll skip this.
Great point, and something which belongs in this thread !
For example, I have a string of i2c sensors, with 4 wires - red and black connected to V+ and GND on the breadboard, and SCL and SDA connected to processor GPIO pins. This means that the sensors (plus additional circuitry and status LEDs on the sensor breakout boards) are getting power even when the processor is asleep. Hopefully this isn’t much … but why waste power when not trying to access the sensors ? Consider:
- connect the i2c V+ wire to a third GPIO pin,
- turn that third GPIO pin ON (pull high) while making the measurements
- turn that third GPIO pin OFF when finished taking measurements, so the sensor modules are not getting any power while not actually being used.
And it’s not just i2c which this applies to. There may be some (like relays) which you do want to stay powered while the processor is asleep - but there will be others which can safely be powered off.
I have found with BMP sensors on I2C running on battery that after several months they would fail and only work again after disconnecting power and reconnecting. So by removing power each time the esp goes into deepsleep this hasn’t happened(perhaps I was missing one reading but I didn’t notice this). I was suspicious they were slipping into SPI mode but even with a hard pullup to I2C it still happened. Possibly it was a problem with cheap bmp modules.
Espressif have acknowledged their SOCs draw huge power compared to some other competitors and have recently announced low power chips that are competive, making all these unwieldy workarounds being attempted moot. Inspecting power requirements before chip selection should be rote, but sadly in hobbyist situations, often overlooked. The cost difference with correct chip selection, especially when adding futzing time, is absolutely enormous.
See the H4 and H21 series, and their specifications.
I’ve only been using ESP12F for deepsleep projects (for this reason)and only with mini solar panels. Even D1 mini’s had too much overhead.
It was my own mistake. My meter’s polarity was wrong. Reversing the probes gave a reasonably desirable reading of 26.4 µA in deepsleep.
Not true, changing polarity should not give you 10x readings. Your 26uA is likely as incorrect as 220uA. But you are just happy with the small number.
I gave a high level flow, but some code would be so much more useful. Step 1 is just wiring. Step 2 should be a simple matter of turning the GPIO pin on in on_boot:. And step 3 is easy to turn the pin off in the on_shutdown. Except that its not quite so simple.
-
Note that using a GPIO to switch i2c power on means my ESP32-S3 is supplying 3V3 power and control signals to my i2c devices. Some devices may require 5V power. Alternatively i believe you could use the Output component, which has a
power_supplyconfiguration option. I haven’t tried this myself. -
ESPHome initialises the i2c bus at boot priority 1000 - before almost everything else, including the GPIO pins - and you get errors when it can't find devices because there is no power.
There is a deliberately undocumented option for the i2c component called “setup_priority” that lets you lower the priority of initialising the i2c bus. There is no definitive list of what is done at which priority level; however some users suggest the “setup_parameter” for i2c be set at 600. -
Instead of turning the GPIO switch ON in the on_boot, I have chosen to use
restore_mode: ALWAYS_ONin the GPIO switch definition, thinking this will be done as part of the GPIO pin's initialisation (at whatever boot priority it has). -
If you are still getting the
Recovery failed: SCL is held LOW on the buserror message ... try setting the i2c: scan: option to "false". This skips the initial search of the i2c addresses, which is where that error message is generated. With luck the GPIO.switch should have been initiated before your component which uses the i2c bus is initialised. -
Consider also that ESP32 is multi-threaded - ie reading sensors starts starts in one thread independent of where on_boot: is up to in another thread ... resulting in ESPHome sometimes being unable to find the i2c (or whatever) device when it first tries !
-
I turn i2c power off in on_shutdown:
For example:
i2c:
- id: i2c_control
sda: GPIO40
scl: GPIO41
scan: false # don't do an initial scan
setup_priority: 600 # delay initialising i2s to give a chance for the power to be turned on
switch:
# power for the main control i2c
- platform: gpio
pin: GPIO42
id: enable_i2c_control
name: enable_i2c_control
restore_mode: ALWAYS_ON # let ESPHome turn it ON as part of setup
esphome:
on_shutdown:
- priority: -100
then:
- switch.turn_off: enable_i2c_control # save power by turning off i2c devices while CPU is asleep
I just created a oil level sensor and tamper alert with deep sleep.
I setup the code to measure the oil level every half an hour by coming out of deep sleep. I also set a wakepin with a motion sensor based off a lm393 comparator board. This worked well when tested with USB power of 5v. However when I migrated to 3v7 Battery power it stopped working. A little digging and it turns out that even though the Lm393 can operate off 3v3 supply - it's logic level output is only around 1.29v at this voltage which is insufficient to wake the ESP32-s3 from deep sleep. Once awake it will register 1.29v as logic positive.
So it seems that the wakepin needs a logic signal of at least 3v to wake the board. Something to be aware of when designing your battery powered projects. I am going to use ky-020 and ky-002 boards switching the 3v3 rail as my wake sensors as a solution.