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

ESP32 WiFi Lora Board - deep-sleep power consumption #6

Open
rmh78 opened this Issue Nov 27, 2017 · 35 comments

Comments

Projects
None yet
@rmh78

rmh78 commented Nov 27, 2017

Hardware:

Board: Heltec ESP32 WiFi Lora Board Core
Installation/update date: 25/nov/2017
IDE name: Arduino IDE
Flash Frequency: 80Mhz
Upload Speed: 921600

Description:

I want to set the esp32 to deep sleep mode and measure the power consumption. The esp32 specification says that the power consumption should be in the µA range. My measurement is between 3mA and 10mA in deep-sleep mode. I'm powering the board with 3.7V lipo on the 3.3V input pin.

Sketch:

#include "esp_sleep.h"

#define uS_TO_S_FACTOR 1000000  /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP  60       /* Time ESP32 will go to sleep (in seconds) */

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

  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
  esp_sleep_pd_config(ESP_PD_DOMAIN_MAX, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
}

void loop(){
  delay(5000);
  esp_deep_sleep_start();
}
@Heltec-Aaron-Lee

This comment has been minimized.

Show comment
Hide comment
@Heltec-Aaron-Lee

Heltec-Aaron-Lee Nov 28, 2017

Owner

Seems you did't turn off the OLED's charger pump and set OLED into sleep mode, you may test with fellow codes:

display.sendCommand(0x8D); //into charger pump set mode
display.sendCommand(0x10); //turn off charger pump
display.sendCommand(0xAE); //set OLED sleep

Owner

Heltec-Aaron-Lee commented Nov 28, 2017

Seems you did't turn off the OLED's charger pump and set OLED into sleep mode, you may test with fellow codes:

display.sendCommand(0x8D); //into charger pump set mode
display.sendCommand(0x10); //turn off charger pump
display.sendCommand(0xAE); //set OLED sleep

@urs8000

This comment has been minimized.

Show comment
Hide comment
@urs8000

urs8000 Nov 28, 2017

display.sendCommand(0x8D);
what additional library and initialization is needed for the three commands?
thanks for your help & info

urs8000 commented Nov 28, 2017

display.sendCommand(0x8D);
what additional library and initialization is needed for the three commands?
thanks for your help & info

@rmh78

This comment has been minimized.

Show comment
Hide comment
@rmh78

rmh78 Nov 28, 2017

@Heltec-Aaron-Lee
STILL NOT WORKING
I changed my sample program and added the lines of code to turn off the OLED charger pump and the OLED itself. But the power consumption stays the same (about 5mA). Any other suggestions to reduce power consumption down in the µA range. It would be great if you can provide us with an arduino sketch.

This is my changed program. Please double-check it.

#include <Wire.h>
#include "SSD1306.h"
#include "esp_sleep.h"

#define uS_TO_S_FACTOR 1000000  /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP  20       /* Time ESP32 will go to sleep (in seconds) */
RTC_DATA_ATTR int bootCount = 0;

SSD1306 display(0x3c, 4, 15);

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

  initOled();
  display.drawString(0, 0, "hello world");
  display.display();
  delay(2000); 

  sendCommand(0x8D); //into charger pump set mode
  sendCommand(0x10); //turn off charger pump
  sendCommand(0xAE); //set OLED sleep

  delay(5000);
  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
  esp_sleep_pd_config(ESP_PD_DOMAIN_MAX, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
  esp_deep_sleep_start();
}

void loop()
{
}

void initOled() 
{
  pinMode(16,OUTPUT);
  digitalWrite(16, LOW);    // set GPIO16 low to reset OLED
  delay(50); 
  digitalWrite(16, HIGH);   // while OLED is running, must set GPIO16 in high

  display.init();
  display.flipScreenVertically();
  display.setFont(ArialMT_Plain_10);
  display.clear();
}

void sendCommand(unsigned char command)
{
  Wire.beginTransmission(0x3C); // oled adress
  Wire.write(0x80); // command mode
  Wire.write(command);
  Wire.endTransmission();
}

rmh78 commented Nov 28, 2017

@Heltec-Aaron-Lee
STILL NOT WORKING
I changed my sample program and added the lines of code to turn off the OLED charger pump and the OLED itself. But the power consumption stays the same (about 5mA). Any other suggestions to reduce power consumption down in the µA range. It would be great if you can provide us with an arduino sketch.

This is my changed program. Please double-check it.

#include <Wire.h>
#include "SSD1306.h"
#include "esp_sleep.h"

#define uS_TO_S_FACTOR 1000000  /* Conversion factor for micro seconds to seconds */
#define TIME_TO_SLEEP  20       /* Time ESP32 will go to sleep (in seconds) */
RTC_DATA_ATTR int bootCount = 0;

SSD1306 display(0x3c, 4, 15);

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

  initOled();
  display.drawString(0, 0, "hello world");
  display.display();
  delay(2000); 

  sendCommand(0x8D); //into charger pump set mode
  sendCommand(0x10); //turn off charger pump
  sendCommand(0xAE); //set OLED sleep

  delay(5000);
  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
  esp_sleep_pd_config(ESP_PD_DOMAIN_MAX, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
  esp_deep_sleep_start();
}

void loop()
{
}

void initOled() 
{
  pinMode(16,OUTPUT);
  digitalWrite(16, LOW);    // set GPIO16 low to reset OLED
  delay(50); 
  digitalWrite(16, HIGH);   // while OLED is running, must set GPIO16 in high

  display.init();
  display.flipScreenVertically();
  display.setFont(ArialMT_Plain_10);
  display.clear();
}

void sendCommand(unsigned char command)
{
  Wire.beginTransmission(0x3C); // oled adress
  Wire.write(0x80); // command mode
  Wire.write(command);
  Wire.endTransmission();
}
@urs8000

This comment has been minimized.

Show comment
Hide comment
@urs8000

urs8000 Nov 28, 2017

urs8000 commented Nov 28, 2017

@gbiohazard

This comment has been minimized.

Show comment
Hide comment
@gbiohazard

gbiohazard Dec 3, 2017

Same trouble here, I'm stucked with 10 mA with everything sleeping..
Any solution ?
Thanks

gbiohazard commented Dec 3, 2017

Same trouble here, I'm stucked with 10 mA with everything sleeping..
Any solution ?
Thanks

@gbiohazard

This comment has been minimized.

Show comment
Hide comment
@gbiohazard

gbiohazard Dec 3, 2017

I removed the oled display and the board is still draining 10mA.

gbiohazard commented Dec 3, 2017

I removed the oled display and the board is still draining 10mA.

@thomashoeky

This comment has been minimized.

Show comment
Hide comment
@thomashoeky

thomashoeky Dec 29, 2017

Is there any news about this?

thomashoeky commented Dec 29, 2017

Is there any news about this?

@baxtery

This comment has been minimized.

Show comment
Hide comment
@baxtery

baxtery Jan 14, 2018

powering at 5v : i have similar measurements, with LoRa and DHT-> 94 mA, without Lora active 46 mA and in deep sleep 11 mA.
sleep and wake up works fine
powering at 3.3v, i get 31mA but thats it, no sleep, how did u poer at 3.3 directly?

baxtery commented Jan 14, 2018

powering at 5v : i have similar measurements, with LoRa and DHT-> 94 mA, without Lora active 46 mA and in deep sleep 11 mA.
sleep and wake up works fine
powering at 3.3v, i get 31mA but thats it, no sleep, how did u poer at 3.3 directly?

@kovir

This comment has been minimized.

Show comment
Hide comment
@kovir

kovir Feb 15, 2018

@baxtery Have You got DHT sensor (temp and humid) working with OLED?

kovir commented Feb 15, 2018

@baxtery Have You got DHT sensor (temp and humid) working with OLED?

@agirolami87

This comment has been minimized.

Show comment
Hide comment
@agirolami87

agirolami87 Mar 8, 2018

Same issue, in deep sleep mode 11mA.
Any news ?
Thanks

agirolami87 commented Mar 8, 2018

Same issue, in deep sleep mode 11mA.
Any news ?
Thanks

@DeuxVis

This comment has been minimized.

Show comment
Hide comment
@DeuxVis

DeuxVis Mar 8, 2018

This maybe can help reduce the consumption : #17 (comment)

"If you power the device from the 3.3V pin the battery charger won't be enabled"

DeuxVis commented Mar 8, 2018

This maybe can help reduce the consumption : #17 (comment)

"If you power the device from the 3.3V pin the battery charger won't be enabled"

@agirolami87

This comment has been minimized.

Show comment
Hide comment
@agirolami87

agirolami87 Mar 8, 2018

@DeuxVis I already tried in my tests, but without improvements.

agirolami87 commented Mar 8, 2018

@DeuxVis I already tried in my tests, but without improvements.

@adriancuzman

This comment has been minimized.

Show comment
Hide comment
@adriancuzman

adriancuzman Mar 14, 2018

I have 2 boards, both have this issue, in deep sleep power consumption is ~17 mA. So it can't be used on battery power. Please tell us if this is a software issue or a hardware design issue.

adriancuzman commented Mar 14, 2018

I have 2 boards, both have this issue, in deep sleep power consumption is ~17 mA. So it can't be used on battery power. Please tell us if this is a software issue or a hardware design issue.

@adriancuzman

This comment has been minimized.

Show comment
Hide comment
@adriancuzman

adriancuzman Mar 14, 2018

Also, where can we review the hardware design/schematic?

adriancuzman commented Mar 14, 2018

Also, where can we review the hardware design/schematic?

@gbiohazard

This comment has been minimized.

Show comment
Hide comment
@gbiohazard

gbiohazard Mar 14, 2018

Hi,

It is hardware design issue.
TM.

gbiohazard commented Mar 14, 2018

Hi,

It is hardware design issue.
TM.

@ToninoTarsi

This comment has been minimized.

Show comment
Hide comment
@ToninoTarsi

ToninoTarsi Mar 16, 2018

I'm thinking to use this board for my project but 10mA in deep sleep will be a very big problem.
Did someone solve this problem ?

ToninoTarsi commented Mar 16, 2018

I'm thinking to use this board for my project but 10mA in deep sleep will be a very big problem.
Did someone solve this problem ?

@adriancuzman

This comment has been minimized.

Show comment
Hide comment
@adriancuzman

adriancuzman commented Mar 17, 2018

@gbiohazard Thank you

@ayhoung

This comment has been minimized.

Show comment
Hide comment
@ayhoung

ayhoung Mar 19, 2018

@gbiohazard any clue where the specific issue is?

ayhoung commented Mar 19, 2018

@gbiohazard any clue where the specific issue is?

@gbiohazard

This comment has been minimized.

Show comment
Hide comment
@gbiohazard

gbiohazard Mar 19, 2018

Here are the tests I made (initially on https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-1/10247)

Using Heltec LoRa board:
Deep sleep 10.2mA
Deep sleep OLED Off 10.2mA
Deep sleep OLED unsoldered 10mA
Deep sleep OLED and BMS (battery managing system (mcp73831 ?)) and LED remvoed : 2.6mA
Deel sleep without : OLED, BMS, LED, CP210x : 2.6mA

Using Esp32 Core Board (LED removed):
Deep sleep 4.5µA

Using ESP32 Core Board (LED removed) and NiceRF LoRa1276 (sx1276 based module):
Deep sleep 1.76mA

Analysis:
The sx127x can reach 1µA in deep sleep, so the total would be 5.5µA. BUT, the crystal used
is a TCXO, which remains powered continuously.
As I explained in thethingsnetwork topic, you'll have to power off the crystal (e.g. using µC pin and Mosfet) to achieve the expected low power consumption in deep sleep mode. If you still want to deep sleep µC while the LoRa is in listing mode (µC wake up by interrupt), the µC pin must be able to hold its state in deep sleep (the esp32 can on specific RTC pins).

See:

esp_err_t rtc_gpio_hold_en(gpio_num_t gpio_num)
Enabling HOLD function will cause the pad to latch current values of input enable, output enable, output value, function, drive strength values. This function is useful when going into light or deep sleep mode to prevent the pin configuration from changing.

Sorry for my english (FR).

gbiohazard commented Mar 19, 2018

Here are the tests I made (initially on https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-1/10247)

Using Heltec LoRa board:
Deep sleep 10.2mA
Deep sleep OLED Off 10.2mA
Deep sleep OLED unsoldered 10mA
Deep sleep OLED and BMS (battery managing system (mcp73831 ?)) and LED remvoed : 2.6mA
Deel sleep without : OLED, BMS, LED, CP210x : 2.6mA

Using Esp32 Core Board (LED removed):
Deep sleep 4.5µA

Using ESP32 Core Board (LED removed) and NiceRF LoRa1276 (sx1276 based module):
Deep sleep 1.76mA

Analysis:
The sx127x can reach 1µA in deep sleep, so the total would be 5.5µA. BUT, the crystal used
is a TCXO, which remains powered continuously.
As I explained in thethingsnetwork topic, you'll have to power off the crystal (e.g. using µC pin and Mosfet) to achieve the expected low power consumption in deep sleep mode. If you still want to deep sleep µC while the LoRa is in listing mode (µC wake up by interrupt), the µC pin must be able to hold its state in deep sleep (the esp32 can on specific RTC pins).

See:

esp_err_t rtc_gpio_hold_en(gpio_num_t gpio_num)
Enabling HOLD function will cause the pad to latch current values of input enable, output enable, output value, function, drive strength values. This function is useful when going into light or deep sleep mode to prevent the pin configuration from changing.

Sorry for my english (FR).

@baxtery

This comment has been minimized.

Show comment
Hide comment
@baxtery

baxtery Mar 19, 2018

i think we should design a PCB with a step up, a mosfet, esp32 and an SX1276 and wait for someone in china to copy it and sell it cheap on aliexpress :)

baxtery commented Mar 19, 2018

i think we should design a PCB with a step up, a mosfet, esp32 and an SX1276 and wait for someone in china to copy it and sell it cheap on aliexpress :)

@baxtery

This comment has been minimized.

Show comment
Hide comment
@baxtery

baxtery Mar 19, 2018

but if we power off the sx, does OTAA still work after waking up from deepsleep?

baxtery commented Mar 19, 2018

but if we power off the sx, does OTAA still work after waking up from deepsleep?

@mpatafio

This comment has been minimized.

Show comment
Hide comment
@mpatafio

mpatafio Mar 26, 2018

@kovir I did it! use the PIN 22 ;)

mpatafio commented Mar 26, 2018

@kovir I did it! use the PIN 22 ;)

@goran-mahovlic

This comment has been minimized.

Show comment
Hide comment
@goran-mahovlic

goran-mahovlic Mar 28, 2018

I did try to wirite 0x00 to REG_TCXO - and get same consumption.

Do you have some working schematic how should TXCO powering look?

I did check schematics now and my measuring are for 32k clock...

dio1 It is off when in sleep and has only slight jump when sending
Ok connected scope and it is only powered on while transmitting...
Sending is set to SF7.

dscf0298

goran-mahovlic commented Mar 28, 2018

I did try to wirite 0x00 to REG_TCXO - and get same consumption.

Do you have some working schematic how should TXCO powering look?

I did check schematics now and my measuring are for 32k clock...

dio1 It is off when in sleep and has only slight jump when sending
Ok connected scope and it is only powered on while transmitting...
Sending is set to SF7.

dscf0298

@goran-mahovlic

This comment has been minimized.

Show comment
Hide comment
@goran-mahovlic

goran-mahovlic Mar 29, 2018

But then you can check this module it claims StandBy current is 1uA and it does not have pin to enable disable TXCO so it should be somehow possible to disable it with registers...
Dorji

There is some code in pdf files So I will try this at home ...

void sx1276_7_8_Standby(void)
{
//SPIWrite(LR_RegOpMode,0x09); //Standby//Low
Frequency Mode
SPIWrite(LR_RegOpMode,0x01); //Standby//High
Frequency Mode
SPIWrite(REG_LR_DIOMAPPING2,0x40); //DIO4 01
}
/**********************************************************
**Name: sx1276_7_8_Sleep
**Function: Entry sleep mode
**Input: None
**Output: None
**********************************************************/
void sx1276_7_8_Sleep(void)
{
//SPIWrite(LR_RegOpMode,0x08); //Sleep//Low
Frequency Mode
SPIWrite(LR_RegOpMode,0x00); //Sleep//High
Frequency Mode
SPIWrite(REG_LR_DIOMAPPING2,0x40); //DIO4 01
}

goran-mahovlic commented Mar 29, 2018

But then you can check this module it claims StandBy current is 1uA and it does not have pin to enable disable TXCO so it should be somehow possible to disable it with registers...
Dorji

There is some code in pdf files So I will try this at home ...

void sx1276_7_8_Standby(void)
{
//SPIWrite(LR_RegOpMode,0x09); //Standby//Low
Frequency Mode
SPIWrite(LR_RegOpMode,0x01); //Standby//High
Frequency Mode
SPIWrite(REG_LR_DIOMAPPING2,0x40); //DIO4 01
}
/**********************************************************
**Name: sx1276_7_8_Sleep
**Function: Entry sleep mode
**Input: None
**Output: None
**********************************************************/
void sx1276_7_8_Sleep(void)
{
//SPIWrite(LR_RegOpMode,0x08); //Sleep//Low
Frequency Mode
SPIWrite(LR_RegOpMode,0x00); //Sleep//High
Frequency Mode
SPIWrite(REG_LR_DIOMAPPING2,0x40); //DIO4 01
}

@goran-mahovlic

This comment has been minimized.

Show comment
Hide comment
@goran-mahovlic

goran-mahovlic Mar 31, 2018

Without removing any hardware parts I am down to 4mA.
And putting the same code on ESP32 Devkit V1 board got 5mA
1mA more is probably because LED that is connected directly to 3.3V
And I can see online that this board has problems with low power to...

So I would say that SX part is maybe not the problem.

Problem could be that we maybe need to check is ESP really going to right SLEEP mode.
I have read that for true ultra low power you need to recompile few files to enable only one CPU core and set 32KHz as a main oscillator in LPM. I did try something but still have higher consumption then in original repo...

Removing BMS and LEDS did not lower consumption got 4-5mA with and without BMS.

Put BMS back did not put LEDS back and now I have 2.56mA (It was 4 without LEDS, maybe I did change something in code but I do not think I did)

My instrument cannot get consumption in mA while SX is sending so Im powering from USB until first send, and after that I disconnect USB...
It seams that connecting it just to USB first and disconnecting it from USB did the trick with lowering to 2.5mA - If I just start same code just from battery it drains 10mA.
After that it just powering up every minute and sends messages and goes into sleep consuming 2.5mA

https://gist.github.com/goran-mahovlic/72833b26fd61ecc04fcf0f74bffad575

https://youtu.be/Dt8NZsSrXiM

goran-mahovlic commented Mar 31, 2018

Without removing any hardware parts I am down to 4mA.
And putting the same code on ESP32 Devkit V1 board got 5mA
1mA more is probably because LED that is connected directly to 3.3V
And I can see online that this board has problems with low power to...

So I would say that SX part is maybe not the problem.

Problem could be that we maybe need to check is ESP really going to right SLEEP mode.
I have read that for true ultra low power you need to recompile few files to enable only one CPU core and set 32KHz as a main oscillator in LPM. I did try something but still have higher consumption then in original repo...

Removing BMS and LEDS did not lower consumption got 4-5mA with and without BMS.

Put BMS back did not put LEDS back and now I have 2.56mA (It was 4 without LEDS, maybe I did change something in code but I do not think I did)

My instrument cannot get consumption in mA while SX is sending so Im powering from USB until first send, and after that I disconnect USB...
It seams that connecting it just to USB first and disconnecting it from USB did the trick with lowering to 2.5mA - If I just start same code just from battery it drains 10mA.
After that it just powering up every minute and sends messages and goes into sleep consuming 2.5mA

https://gist.github.com/goran-mahovlic/72833b26fd61ecc04fcf0f74bffad575

https://youtu.be/Dt8NZsSrXiM

@schabauerj

This comment has been minimized.

Show comment
Hide comment
@schabauerj

schabauerj Jun 19, 2018

Hi Goran,
Thank you so much for taking the time to describe this issue. I tested with 3 different boards and thought I was crazy.

I have the same issue: If I plug my board into a USB-plug (and the Linux recognizes the new device), the power consumption is around 3mA. If I only power form Lipo (or a USB Power Bank), it is 11.7mA (with some sensors). If I power with Computer first and then hotswap to Battery, 3mA remain.
With 3mA my Battery application could last almost half a year (4x18650 with 3500mA), but 11,7mA is really a pain.
I thought I would change the startup code and began with disabling the Serial (Serial.end()) port before esp_deep_sleep_start(), but that would have been too nice :-) Then I digged depper in "/home/nemo/arduino-1.8.5/hardware/espressif/esp32/cores/esp32", but couldn't find the startup code for the serial port. Do you have any idea? Or is it hidden in Rom?

schabauerj commented Jun 19, 2018

Hi Goran,
Thank you so much for taking the time to describe this issue. I tested with 3 different boards and thought I was crazy.

I have the same issue: If I plug my board into a USB-plug (and the Linux recognizes the new device), the power consumption is around 3mA. If I only power form Lipo (or a USB Power Bank), it is 11.7mA (with some sensors). If I power with Computer first and then hotswap to Battery, 3mA remain.
With 3mA my Battery application could last almost half a year (4x18650 with 3500mA), but 11,7mA is really a pain.
I thought I would change the startup code and began with disabling the Serial (Serial.end()) port before esp_deep_sleep_start(), but that would have been too nice :-) Then I digged depper in "/home/nemo/arduino-1.8.5/hardware/espressif/esp32/cores/esp32", but couldn't find the startup code for the serial port. Do you have any idea? Or is it hidden in Rom?

@goran-mahovlic

This comment has been minimized.

Show comment
Hide comment
@goran-mahovlic

goran-mahovlic Jun 20, 2018

There is only one thing I have read after my post in TTN forum, but did not have time to try:
https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-2/11973/568

When you put the ESP32 into deep sleep the GPIO pins go into high impedance mode, which is not good for devices on the SPI bus, such as LoRa.
With the SPI bus high Z the LoRa device (also in sleep mode) takes the sleep current up to 120uA, not good.
If you add pullup resistors on the 3 SPI pins and the LoRa device select pin, sleep current of an ESP32 and LoRa device is 7uA.
Also note that although you should be able to leave the LoRa NRESET pin floating (it has its own internal pullup) if your driving it with the ESP32 then add an external pullup resistor, the ESP32 in deep sleep drags this pin low.

goran-mahovlic commented Jun 20, 2018

There is only one thing I have read after my post in TTN forum, but did not have time to try:
https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-2/11973/568

When you put the ESP32 into deep sleep the GPIO pins go into high impedance mode, which is not good for devices on the SPI bus, such as LoRa.
With the SPI bus high Z the LoRa device (also in sleep mode) takes the sleep current up to 120uA, not good.
If you add pullup resistors on the 3 SPI pins and the LoRa device select pin, sleep current of an ESP32 and LoRa device is 7uA.
Also note that although you should be able to leave the LoRa NRESET pin floating (it has its own internal pullup) if your driving it with the ESP32 then add an external pullup resistor, the ESP32 in deep sleep drags this pin low.

@gbiohazard

This comment has been minimized.

Show comment
Hide comment
@gbiohazard

gbiohazard Jun 20, 2018

One important thing to understand is that NSS (SPI Cable Select) is active low. In deep sleep mode, the esp32 releases all outputs state to low, so the LoRa chip becomes active again. The trick is to use the rtc_gpio_hold_en(gpio_num_t gpio_num) function to keep HIGH the NSS pin.

But wait, in deep sleep mode, only some specific pins are available to control: RTC pins.

  • GPIO18, used for NSS on the Heltec LoRa 32, isn't an RTC pins.
  • In deep sleep mode, GPIO18 will always go low
  • In deep sleep, LoRa chip will always be in standby mode (about 1.5 mA).

With my LoRa1276 (NiceRF) module, it stays <1µA when the esp32 is in deep sleep (GPIO04 NSS)

gbiohazard commented Jun 20, 2018

One important thing to understand is that NSS (SPI Cable Select) is active low. In deep sleep mode, the esp32 releases all outputs state to low, so the LoRa chip becomes active again. The trick is to use the rtc_gpio_hold_en(gpio_num_t gpio_num) function to keep HIGH the NSS pin.

But wait, in deep sleep mode, only some specific pins are available to control: RTC pins.

  • GPIO18, used for NSS on the Heltec LoRa 32, isn't an RTC pins.
  • In deep sleep mode, GPIO18 will always go low
  • In deep sleep, LoRa chip will always be in standby mode (about 1.5 mA).

With my LoRa1276 (NiceRF) module, it stays <1µA when the esp32 is in deep sleep (GPIO04 NSS)

@schabauerj

This comment has been minimized.

Show comment
Hide comment
@schabauerj

schabauerj Jun 20, 2018

Chip Select and Active Low is a good point :-)
I will try this out and might be able to safe 1-2mA.
However, I don't see this connected to the "Plug me into a proper USB host first if you want low power Problem." Only after the USB-Serial converter is recognized by a host, the deep sleep power drops from around 10 to 3mA. However, if it restarts on Battery, it will be 10mA again.
This might be a bad design issue. I read that the firebeetle-esp32 has a good low power of less than 1mA. Which boards can you recommend?

schabauerj commented Jun 20, 2018

Chip Select and Active Low is a good point :-)
I will try this out and might be able to safe 1-2mA.
However, I don't see this connected to the "Plug me into a proper USB host first if you want low power Problem." Only after the USB-Serial converter is recognized by a host, the deep sleep power drops from around 10 to 3mA. However, if it restarts on Battery, it will be 10mA again.
This might be a bad design issue. I read that the firebeetle-esp32 has a good low power of less than 1mA. Which boards can you recommend?

@bradmcl

This comment has been minimized.

Show comment
Hide comment
@bradmcl

bradmcl Jul 8, 2018

So, if the schematics at https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/tree/master/SchematicDiagram are correct, and I'm reading the info on the CP2102 correctly at https://www.silabs.com/documents/public/data-sheets/CP2102-9.pdf and https://www.silabs.com/community/interface/knowledge-base.entry.html/2004/04/20/cp210x_current_draw-OUVM then it appears that if you start with a USB host, the CP2102 goes active, and then goes to Suspend after the USB is disconnected. If you just power up on battery, then it stays active looking for a USB connection. Apparently if there were a way to force the reset pin low you would get the Suspend level of power usage, but this board feeds the 5V bus from VBAT as part of the LDO circuit. If there was another diode in the LDO circuit between 5V and pin 1 of the U1 LDO ( and possibly a weak pulldown on pin 9 !RST of the CP2102 it would likely eliminate the problem; alternatively, if there was a way to use software to pull pin 9 !RST of the CP2102 low - by wiring it to an IO pin ( 3.3v vs 5v issue to solve ) then you could also force the state. So as others have said elsewhere, it is a hardware design issue on this board.

Depending on the board layout, it may be possible to cut a trace to isolate 5V from VBAT; you would be required to power the board separately from the USB even when using the USB, but it might solve the power drain when not on USB.

bradmcl commented Jul 8, 2018

So, if the schematics at https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/tree/master/SchematicDiagram are correct, and I'm reading the info on the CP2102 correctly at https://www.silabs.com/documents/public/data-sheets/CP2102-9.pdf and https://www.silabs.com/community/interface/knowledge-base.entry.html/2004/04/20/cp210x_current_draw-OUVM then it appears that if you start with a USB host, the CP2102 goes active, and then goes to Suspend after the USB is disconnected. If you just power up on battery, then it stays active looking for a USB connection. Apparently if there were a way to force the reset pin low you would get the Suspend level of power usage, but this board feeds the 5V bus from VBAT as part of the LDO circuit. If there was another diode in the LDO circuit between 5V and pin 1 of the U1 LDO ( and possibly a weak pulldown on pin 9 !RST of the CP2102 it would likely eliminate the problem; alternatively, if there was a way to use software to pull pin 9 !RST of the CP2102 low - by wiring it to an IO pin ( 3.3v vs 5v issue to solve ) then you could also force the state. So as others have said elsewhere, it is a hardware design issue on this board.

Depending on the board layout, it may be possible to cut a trace to isolate 5V from VBAT; you would be required to power the board separately from the USB even when using the USB, but it might solve the power drain when not on USB.

@lois-lee

This comment has been minimized.

Show comment
Hide comment
@lois-lee

lois-lee Aug 15, 2018

@urs8000 Mine is also not waking up after the esp_deep_sleep_start() call, did you ever fix the problem?

lois-lee commented Aug 15, 2018

@urs8000 Mine is also not waking up after the esp_deep_sleep_start() call, did you ever fix the problem?

@urs8000

This comment has been minimized.

Show comment
Hide comment
@urs8000

urs8000 Aug 17, 2018

@lois-lee my Heltec-WiFi board is working with the original code above from @rmh78
Tested with the new Arduino Setup (WIN10/IDE 1.8.5) and board=Heltec_WIFI_Kit_32
I do not longer work with that boards. (also not with lora version)

urs8000 commented Aug 17, 2018

@lois-lee my Heltec-WiFi board is working with the original code above from @rmh78
Tested with the new Arduino Setup (WIN10/IDE 1.8.5) and board=Heltec_WIFI_Kit_32
I do not longer work with that boards. (also not with lora version)

@myszko

This comment has been minimized.

Show comment
Hide comment
@myszko

myszko Sep 1, 2018

According with my tests the issue is related to the USB mode as mentioned previously by @bradmcl. Even with ESP32 on sleep mode and OLED disabled the node still drains 8-10mA. If I connect the USB to a PC and the PC recognizes it and after that disconect the cable, the current reduces to 1,3mA. This happens because the CP2102 goes to SUSPPEND MODE.
For my case 1,3 mA is fine.

However the question is if there is any way (SW or HW) to force the CP2102 to susppend mode.
Does anyone have any idea on this issue?

myszko commented Sep 1, 2018

According with my tests the issue is related to the USB mode as mentioned previously by @bradmcl. Even with ESP32 on sleep mode and OLED disabled the node still drains 8-10mA. If I connect the USB to a PC and the PC recognizes it and after that disconect the cable, the current reduces to 1,3mA. This happens because the CP2102 goes to SUSPPEND MODE.
For my case 1,3 mA is fine.

However the question is if there is any way (SW or HW) to force the CP2102 to susppend mode.
Does anyone have any idea on this issue?

@schabauerj

This comment has been minimized.

Show comment
Hide comment
@schabauerj

schabauerj Sep 5, 2018

@myszko: How did you measure 1,3mA? I use the UM25 USB Meter and it shows 3mA. Is there a new version of the board? Concerning the CP2102 I have no idea how to force it to sleep mode, other than plugging it into a usb-connector and unplugging it.
@urs8000: My esp32 never had a problem waking up from deepsleep UNTIL I deployed them in a bigger home automation project (12 sensors - not toooo big) and within 2 months two sensors did not wake up one time after 5 minutes of deep sleep. After hitting the reset button, everything worked fine, but the uneasy feeling remains. Any ideas?

schabauerj commented Sep 5, 2018

@myszko: How did you measure 1,3mA? I use the UM25 USB Meter and it shows 3mA. Is there a new version of the board? Concerning the CP2102 I have no idea how to force it to sleep mode, other than plugging it into a usb-connector and unplugging it.
@urs8000: My esp32 never had a problem waking up from deepsleep UNTIL I deployed them in a bigger home automation project (12 sensors - not toooo big) and within 2 months two sensors did not wake up one time after 5 minutes of deep sleep. After hitting the reset button, everything worked fine, but the uneasy feeling remains. Any ideas?

@urs8000

This comment has been minimized.

Show comment
Hide comment
@urs8000

urs8000 Sep 5, 2018

@schabauerj sorry I've no long term experience with ESP32. How did you wake it up?
Probably using the ULP as a watchdo could help if it does not wake up on your method...

urs8000 commented Sep 5, 2018

@schabauerj sorry I've no long term experience with ESP32. How did you wake it up?
Probably using the ULP as a watchdo could help if it does not wake up on your method...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment