Heltec-Aaron-Lee / WiFi_Kit_series

Arduino source codes and toolchain for WiFi_Kit_series made by HelTecAutomation.
GNU Lesser General Public License v2.1
732 stars 305 forks source link

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

Open rmh78 opened 6 years ago

rmh78 commented 6 years ago

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();
}
Skipper-is commented 5 years ago

I'm using the TTGO LoRa32, or possibly a clone. I think it might be a clone, as it has truly abysmal RSSI even at close range...

Heltec-Aaron-Lee commented 5 years ago

@Skipper-is image Here is a document about how to test the maximum communication distance: https://docs.heltec.cn/#/en/user_manual/lora_maximum_communication_distance_test

We spent a lot of time on impendence matching. it's very important for an RF board. You can try our Wireless Stick Lite, it's the cheapest one currently. Maybe you buy from a reseller can have a cheaper price.

Anyway, another new LoRa board is in design and production, it's based on an all-new platform, with good low power design (5uA) and good RF design. and the price may lower than 10 USD. Currently, it still in debugging and waiting for some certificates. We will release it on August 1st.

Skipper-is commented 5 years ago

Yea, I might wait for that one. The 4 I've got have an average of RSSI -75, sitting about 1 meter apart on my desk.... Any battery management with the new module? My intention is to link up a solar cell and a 18650 LiPo for power

Heltec-Aaron-Lee commented 5 years ago

Yes, of course.

Skipper-is commented 5 years ago

Safety cutoff for the batteries? (Also, just ordered 2 of the Wireless Stick Lites from your site! I'll have to check your new one out when it is released in August)

Heltec-Aaron-Lee commented 5 years ago

@Skipper-is you mean when battery is full, the circuit will stop charging? YES

Skipper-is commented 5 years ago

Or when it is discharged, that it'll shut off before damaging the battery

kampto commented 5 years ago

It can not. The EN pin on the regulator is not broken out. Very problematic for remote battery powered sensors.

Regarding power consumption on the V2 board during deep sleep I could not get it below 10ma after a reset.

For these reasons and others I switched to another brand Lora board for remote battery/solar sensors. Still running this board as a house powered receiver of other Lora brand boards.

Sent from my iPhone

On Jun 17, 2019, at 11:10 PM, Skipper notifications@github.com wrote:

Or when it is discharged, that it'll shut off before damaging the battery

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

sle118 commented 4 years ago

@frankheisig71

Hi guys, maybe a little late, but I had the same problem with TTGO LoRa32 (V1) deep sleep power consumption and I managed it by cutting the LDO from 5V circuit and by soldering the LiPo directly to LDO.

I tried replicating your approach and couldn't get down to your numbers; the best I can achieve is ~4mA. I did cut the USB +5V trace that goes from the USB right next to the LDO's input. Then I soldered the battery to the 3.3V breakout pin on the board (e.g. bypassing the LDO).

Did you solder the lipo to the LDO's input or to its output pin (bypassing it entirely)? Also, are you doing anything special to get to sleep?

dahutte commented 4 years ago

Confirmation on Heltec Aaron Lee comment: On 3 recently buyed modules ESP32 Heltec Lora V2, I measure 0.9 mA in deepsleep mode, but I dont understand why it is not less. On the shematic, I find the flash chip which can draw such current? It would be a far progress (mandatory for me) to get lower than ~150uA at deepsleep and the CPU allows this. On an other side, RF power is limited to 17dbm on my 3 modules. I will be very interested in improvement of rf matching. I wait any info on this on future versions. Thanks anymore for the huge info I read from this forum.

Heltec-Aaron-Lee commented 4 years ago

Because the WiFi LoRa 32 uses an external FLASH, the running codes are inside, it's can't sleep during the ESP32 sleeping time.

Heltec-Aaron-Lee commented 4 years ago

@dahutte Anyway, you can choose from our LoRa Node family, there are some other nodes with better low power design.

Penagwin commented 4 years ago

@Heltec-Aaron-Lee I'm currently experimenting with the v2 ESP32/LORA OLED models, what do you recommend for low power usage with solar?

PyramidSlayer commented 4 years ago

@dahutte Anyway, you can choose from our LoRa Node family, there are some other nodes with better low power design.

Hi. I have used the Wireless Stick Lite (Panda Board), and it's consumption in sleep mode is of 3-4 mA. The specs says that the consumption in this state is of 30 uA, not 3-4 mA. The quiestion is, there's a way to achieve this low consumption with this board?

andrelmbraga commented 4 years ago

@dahutte Anyway, you can choose from our LoRa Node family, there are some other nodes with better low power design.

Hi. I have used the Wireless Stick Lite (Panda Board), and it's consumption in sleep mode is of 3-4 mA. The specs says that the consumption in this state is of 30 uA, not 3-4 mA. The quiestion is, there's a way to achieve this low consumption with this board?

I have the same board and I could achieve around 20-30 uA. How are you supplying your board? I highly recommend to power in the battery pins, normally if you supply with 5 V in usb you are going to have higher consumption.

PyramidSlayer commented 4 years ago

I was powering the board through the 3.3V pin and got 3-4 mA. Now I powered it with the battery pins (the two pins under the board connector type) and I got 2.5 mA. If I'm wrong refering me to the battery pins, let me know please and tell me what are the true battery pins.

andrelmbraga commented 4 years ago

Yes, I'm using the two pins under the board with the 1.25 mm connector. Now I'm wondering about your code, or if there is any sensor connected to your Vext, if this is the case you must put the Vext pin on high before goes to sleep mode. Can you show me your code?

andrelmbraga commented 4 years ago

Try the Low_Power example without any extra sensor connected to the board.

` /*

include "heltec.h"

define uS_TO_S_FACTOR 1000000 / Conversion factor for micro seconds to seconds /

define TIME_TO_SLEEP 10 / Time ESP32 will go to sleep (in seconds) /

define BAND 433E6 //you can set band here directly,e.g. 868E6,915E6

RTC_DATA_ATTR int bootCount = 0;

/ Method to print the reason by which ESP32 has been awaken from sleep / void print_wakeup_reason(){ esp_sleep_wakeup_cause_t wakeup_reason;

wakeup_reason = esp_sleep_get_wakeup_cause();

switch(wakeup_reason) { case 1 : { Serial.println("Wakeup caused by external signal using RTC_IO"); delay(2); } break; case 2 : { Serial.println("Wakeup caused by external signal using RTC_CNTL"); delay(2); } break; case 3 : { Serial.println("Wakeup caused by timer"); delay(2); } break; case 4 : { Serial.println("Wakeup caused by touchpad"); delay(2); } break; case 5 : { Serial.println("Wakeup caused by ULP program"); delay(2); } break; default : { Serial.println("Wakeup was not caused by deep sleep"); delay(2); } break; } }

void setup(){ //WIFI Kit series V1 not support Vext control Heltec.begin(true /DisplayEnable Enable/, true /LoRa Disable/, true /Serial Enable/, true /PABOOST Enable/, BAND /long BAND/);

//Increment boot number and print it every reboot ++bootCount; Serial.println("Boot number: " + String(bootCount)); delay(2);

//Print the wakeup reason for ESP32 print_wakeup_reason();

/ First we configure the wake up source We set our ESP32 to wake up every 5 seconds / esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR); Serial.println("Setup ESP32 to sleep for every " + String(TIME_TO_SLEEP) + " Seconds"); delay(10);

/ Next we decide what all peripherals to shut down/keep on By default, ESP32 will automatically power down the peripherals not needed by the wakeup source, but if you want to be a poweruser this is for you. Read in detail at the API docs http://esp-idf.readthedocs.io/en/latest/api-reference/system/deep_sleep.html Left the line commented as an example of how to configure peripherals. The line below turns off all RTC peripherals in deep sleep. / //esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF); //Serial.println("Configured all RTC Peripherals to be powered down in sleep");

/ Now that we have setup a wake cause and if needed setup the peripherals state in deep sleep, we can now start going to deep sleep. In the case that no wake up sources were provided but deep sleep was started, it will sleep forever unless hardware reset occurs. / LoRa.end(); LoRa.sleep(); delay(100);

pinMode(5,INPUT);

pinMode(14,INPUT); pinMode(15,INPUT); pinMode(16,INPUT); pinMode(17,INPUT); pinMode(18,INPUT); pinMode(19,INPUT);

pinMode(26,INPUT); pinMode(27,INPUT);

delay(100); Serial.println("Going to sleep now"); delay(2); esp_deep_sleep_start(); Serial.println("This will never be printed"); }

void loop(){ //This is not going to be called } `

PyramidSlayer commented 4 years ago

Yes, I'm using the two pins under the board with the 1.25 mm connector. Now I'm wondering about your code, or if there is any sensor connected to your Vext, if this is the case you must put the Vext pin on high before goes to sleep mode. Can you show me your code?

Of course. It's a basic sleep mode test code: Sleep test Panda Board.txt

andrelmbraga commented 4 years ago

Try this using arduino IDE: Low_Power.txt

ps.: I had some problems selecting Heltec Wireless Stick as a board, now I'am using Wireless_Stick and works like a charm.

image

PyramidSlayer commented 4 years ago

Oh, I think the problem is that I'm compiling using the configuration for Heltec_Wifi_LoRa_32 instead the configuration of Wireless Stick. I will download this board, upload your code and I will tell you if this works. Thanks dude.

PyramidSlayer commented 4 years ago

Excuse me, where did you get the Heltec.h library? Is not in the downloaded libraries of ESP32.

andrelmbraga commented 4 years ago

In the heltec website you can find some links in Docs and Resources session https://heltec.org/project/wireless-stick-lite/ Here you can find the lib that I'm using: https://github.com/HelTecAutomation/Heltec_ESP32

PyramidSlayer commented 4 years ago

I could compile your program and I just could get 800uA, because the wireless stick lite board appeared in the Heltec ESP32 section, and not in the ESP32 section. i don'tknow if this cause the low consumption problem. Also, I don't understand the issue respecting the Vext pin. If I connect this pin to high voltage(I connected it to the supply voltaje) the current consumption arises from 800uA to 2.5 mA.

andrelmbraga commented 4 years ago

Can you mesure the voltage of your battery? I cannot understand why such I high current consumption.
Another tip is check the battery voltage, it must be around 4.0V. Send pictures showing how are u mesure this current maybe I can find something.

frankheisig71 commented 4 years ago

@sle118

I tried replicating your approach and couldn't get down to your numbers; the best I can achieve is ~4mA. I did cut the USB +5V trace that goes from the USB right next to the LDO's input. Then I soldered the battery to the 3.3V breakout pin on the board (e.g. bypassing the LDO).

Did you solder the lipo to the LDO's input or to its output pin (bypassing it entirely)? Also, are you doing anything special to get to sleep?

Hi sle. I soldered LiPo plus wire to pin 3 of LDO, as you can see on the picture, connected to pin 1 (which is the input of LDO) underneath the chip package. I didn't want to solder it to pin 1 to avoid reconnecting the track I cutted of to disconnect CP2102. Remember: I just want to cut the CP2102 from LiPo connection (see schematics). Soldering Battery to 3.3V breakeout seems not good for me.

@Heltec-Aaron-Lee In deed, it is a (cheap) copy from TTGO - as I mentioned. TTGO_Lora_32_Schematic

frankheisig71 commented 4 years ago

@sle oh, and yes, there is something to do from software side. See andrelmbragas comment. Some GPIOs should set to INPUT.

PyramidSlayer commented 4 years ago

Can you mesure the voltage of your battery? I cannot understand why such I high current consumption. Another tip is check the battery voltage, it must be around 4.0V. Send pictures showing how are u mesure this current maybe I can find something.

Finally, I have reached the low current of 37uA. I realized that the board came faulty from factory, and the minimum current was of 300uA, and unfortunately it was varying from 300 to 1500 uA. I tested other two Panda Boards and, ¡both worked very well saving power! One of them reached 42 uA, and the other one reached 37 uA. Note: There are three fundamental instructions for the lowest save power: -LoRa.begin(433E6,0) -LoRa.end() -pinMode(14,INPUT)

-I powered the board through battery HIGH voltage pin under the board, as Andrelmbraga tolds me. -The voltage of my 18650 Li-Ion battery is of 4.1V (fully charged) -I used a button to sleep and wake my board.

¡Andrelmbraga, thanks a lot for your help my dude! You saved my life jajaja.

I attach one photo and my code: IMG_20190806_190812857 Sleep test Panda Board.txt

andrelmbraga commented 4 years ago

Can you mesure the voltage of your battery? I cannot understand why such I high current consumption. Another tip is check the battery voltage, it must be around 4.0V. Send pictures showing how are u mesure this current maybe I can find something.

Finally, I have reached the low current of 37uA. I realized that the board came faulty from factory, and the minimum current was of 300uA, and unfortunately it was varying from 300 to 1500 uA. I tested other two Panda Boards and, ¡both worked very well saving power! One of them reached 42 uA, and the other one reached 37 uA. Note: There are three fundamental instructions for the lowest save power: -LoRa.begin(433E6,0) -LoRa.end() -pinMode(14,INPUT)

-I powered the board through battery HIGH voltage pin under the board, as Andrelmbraga tolds me. -The voltage of my 18650 Li-Ion battery is of 4.1V (fully charged) -I used a button to sleep and wake my board.

¡Andrelmbraga, thanks a lot for your help my dude! You saved my life jajaja.

I attach one photo and my code: IMG_20190806_190812857 Sleep test Panda Board.txt

You are welcome dude. In fact before Panda's was in the market I did a similar board for my application. However is better to use Panda board because of the price. The input mode for the GPIO's before sleep was made by @Heltec-Aaron-Lee however before him I have tested several different ESP32 and for me depends of the chip so is better put all of them in input before goes to sleep. One tip for future projects: When I use a I2C in the pin 4 as SDA I always open the Vext before to sleep in order to cut the supply however this isnt always enough. Sometimes I need to isolate my pin number 4 (SDA) in order to avoid leakage current. When I do that I use to achieve something around 20 uA. You can always isolate RTC GPIO's using rtc_gpio_isolate(SDA);

leoNavarro95 commented 4 years ago

Hi, I have a heltec wifi-lora v2 and Its consuption in deep sleep (the board only connected to a Li-ion battery) is ~10mA. I read all this page and I tried to fix it with the deep-sleep example of @Heltec-Aaron-Lee and still is in 10mA. I see that the Vext pin when the board is in deep sleep is active (3.3V) so the electronics that is power via Vext is still consuming electric current, and maybe this is the problem. Please some help with that I have tried a week to solve this problem and nothing

sle118 commented 4 years ago

Out of curiosity, did anyone measure the difference between putting the pins to input mode vs isolating the pins altogether? I guess some critical pins cannot be isolated?

Heltec-Aaron-Lee commented 4 years ago

@Skipper-is Hi there After several months of development and testing, the CubeCell series is released!

This is an all-new platform, we made ASR6501/ASR6502 (PSoC 4000 series MCU and SX1262) fully support with Arduino. which is friendly for LoRa developers. Hope you can take a few minutes to look at it, I believe you will like our new project.

Skipper-is commented 4 years ago

Oh awesome! I've just ordered 4 of the dev boards, looking forward to deploying them! Got a couple of wifi stick lite's deployed at the moment, and they're doing really well with battery usage. Really cool that it comes with solar power management and LiPo management, cuts right down on all the extra bits I needed!

Beliwars commented 4 years ago

@frankheisig71 Just for info, I bought 2 TTGO Lora clones (it was for starting a project and was the cheaper I found, for V2 I will buy Panda Boards) anyway I cut the 5V track and souder the lipo + as you said (I also added a jumper to reconnect it to 5V for programming without battery) I got down to 1.18 mA, but I'm not using Heltec library or board descriptor; I set the GPIOs to INPUT as @andrelmbraga said.

My question is: would using the HelTec library help me get even lower (to your 900uA for example)? for my application I'm using MCCI LMIC for connecting to a private ttn like GW (OTAA)

I brought the consumption from 12 to 1.18 mA so I'm mostly happy with the hack.

Thanks in advance and best regards

frankheisig71 commented 4 years ago

@Beliwars not sure if I can help you. all I did is: void goto_sleep(int mseconds){ int ms = millis(); pinMode(5,INPUT); pinMode(14,INPUT); pinMode(15,INPUT); pinMode(16,INPUT); pinMode(17,INPUT); pinMode(18,INPUT); pinMode(19,INPUT); pinMode(26,INPUT); pinMode(27,INPUT); pinMode(GSM,INPUT); pinMode(GPS,INPUT); delay(100); esp_sleep_enable_timer_wakeup((mseconds - (millis() - ms)) * uS_TO_mS_FACTOR); esp_deep_sleep_start(); } hope that will help

Bitbanger1900 commented 4 years ago

Hi,

Did someone tried this heltec wireless stick board with micropython and deep sleep?

With the provided heltec.h library from Lee i got this board into deep sleep with a 40uA
but when i try to do this with micropython and deep sleep i never get this board below the 3mA no matter if i put the pins mentioned above as INPUT.

enwi commented 4 years ago

@Bitbanger1900 How are you achieving 40uA? I can only get my Wireless Stick down to 1mA

Bitbanger1900 commented 4 years ago

@enwi,

i use the heltec wireless stick lite and include the library from lee (https://github.com/HelTecAutomation/Heltec_ESP32/tree/master/src/heltec.h) together with the "BlueDot_BME280.h" and a BME280. set the sensor mode: bme280.parameter.sensorMode = 0b01; when i use 0b11 it takes more power!!

At this moment it is still running since 24.02 measuring every 5 minutes on battery and send it over lora to my receiver.

i would love to have it run micropython but i cannot get the power usage so far down as with Arduino IDE.

enwi commented 4 years ago

Well I don't have the lite version, but would be interested in investigating what is using so much power or could it be the USB chip as well?

Bitbanger1900 commented 4 years ago

According the Heltec site the normal version can put into sleep with 800uA. The lite version also has no SSD1306 what could make the difference.

enwi commented 4 years ago

That could be it, I also tried putting the OLED to sleep, but that did not have any effect on power consumption

Heltec-Aaron-Lee commented 4 years ago

Did you set the unused pin to input mode?

enwi commented 4 years ago

I did

enwi commented 4 years ago

@Beliwars not sure if I can help you. all I did is: void goto_sleep(int mseconds){ int ms = millis(); pinMode(5,INPUT); pinMode(14,INPUT); pinMode(15,INPUT); pinMode(16,INPUT); pinMode(17,INPUT); pinMode(18,INPUT); pinMode(19,INPUT); pinMode(26,INPUT); pinMode(27,INPUT); pinMode(GSM,INPUT); pinMode(GPS,INPUT); delay(100); esp_sleep_enable_timer_wakeup((mseconds - (millis() - ms)) * uS_TO_mS_FACTOR); esp_deep_sleep_start(); } hope that will help

Something similar to this, but added the Heltec.begin with LoRa enabled and set it to sleep (which only works and makes a difference when Heltec.begin gets called, which makes sense)

PyramidSlayer commented 4 years ago

@enwi,

i use the heltec wireless stick lite and include the library from lee (https://github.com/HelTecAutomation/Heltec_ESP32/tree/master/src/heltec.h) together with the "BlueDot_BME280.h" and a BME280. set the sensor mode: bme280.parameter.sensorMode = 0b01; when i use 0b11 it takes more power!!

At this moment it is still running since 24.02 measuring every 5 minutes on battery and send it over lora to my receiver.

i would love to have it run micropython but i cannot get the power usage so far down as with Arduino IDE.

Unfortunately, the wireless stick lite doesn't has a good communication range (I tested two of them in 433 MHz, BW of 500 kHz, SF of 7 and CR 4/5, and the range was of only 100 meters with Line of sight :( ). It consumes in deep mode only 50 uA, but the price to pay is a lesser communication range.

Bitbanger1900 commented 4 years ago

@PyramidSlayer: Did you also do something with the setTxPower?

@Heltec-Aaron-Lee: i find in the examples:

/*

Can you please explain what this is? i cannot find this back in the doc's. What is recomended?

Heltec-Aaron-Lee commented 4 years ago

@Bitbanger1900 This will make sense to you: image

Heltec-Aaron-Lee commented 4 years ago

@PyramidSlayer Did you set TX power? and did make sure the working frequency is matching the hardware? and don't forget the antenna.

Bitbanger1900 commented 4 years ago

Hi Lee,

Thanks for the info! yes, it makes more sense now :)

I did not do any distance tests as it is to cold here but yes i also have to replace the antennas as i ordered the heltecs with 433Mhz but i would say the antenna is for the 868Mhz type and that has of course a significant impact on the distance :)

PyramidSlayer commented 4 years ago

@PyramidSlayer Did you set TX power? and did make sure the working frequency is matching the hardware? and don't forget the antenna.

Yes, I set the TX power to 20 dBm, I used the default pigtail antenna and the software frequency matches the hardware frequency (in my case, 433MHz).