Can't get low power consumption in deep sleep with SPI driver

dernasherbrezon
Posts: 3
Joined: Wed Nov 22, 2023 11:12 pm

Can't get low power consumption in deep sleep with SPI driver

Postby dernasherbrezon » Wed Nov 22, 2023 11:38 pm

Hi,

I have Heltec lora v2 board. It has esp32 and semtech sx127x chips. sx127x is connected via SPI interface. When I'm trying to put both into deep sleep mode, I'm seeing 1.7mA of power consumption. The algorithm is the following:

* init SPI bus ( spi_bus_initialize / spi_bus_add_device )
* read chip version from it (make sure SPI bus works) ( spi_device_polling_transmit )
* put sx127x into sleep mode. Should consume 1uA max. ( spi_device_polling_transmit )
* shutdown SPI device and SPI bus ( spi_bus_remove_device / spi_bus_free )
* put ESP32 into deep sleep ( esp_deep_sleep_start )

However when I measure current using Power Profiler Kit 2, I'm getting ~1.7mA. Which corresponds sx127x standby mode. I double-checked and CS (or SS) pin is HIGH when device is going to sleep.

I found on the Internet that somebody managed to put into ~20uA deep sleep. But they used arduinoespressif32. I tried it like this:
  1. SPI.begin(SCK, MISO, MOSI, SS);
  2. LoRa.begin(BAND, false)
  3. LoRa.sleep();
  4. SPI.end();
  5.  
  6. pinMode(14, INPUT);
  7. pinMode(SCK, INPUT);
  8. pinMode(MISO, INPUT);
  9. pinMode(MOSI, INPUT);
  10. pinMode(SS, INPUT);
  11. pinMode(15, INPUT);
  12. pinMode(16, INPUT);
  13. pinMode(17, INPUT);
  14. pinMode(26, INPUT);
And it worked! So it is possible to archive low power consumption on that board.

I tried different combinations, analysed SPI logic, tried to reproduce Arduino API using C-code, but no luck. Arduino SPI driver is completely different to ESP-IDF SPI driver. It is much simpler, but able to go into deep sleep.

Can someone please help?

I have the following ideas:

* Most likely SPI driver initialise something that was not stopped. Can't find anywhere in the C API.
* Maybe IOMUX or GPIO MUX switched into standby mode and consumed some current
* Power Profiler Kit 2 in the logic analyzer mode outputs only HIGH or LOW, maybe additional PullUP or PullDown is needed

dernasherbrezon
Posts: 3
Joined: Wed Nov 22, 2023 11:12 pm

Re: Can't get low power consumption in deep sleep with SPI driver

Postby dernasherbrezon » Sat Nov 25, 2023 10:48 am

It turned out the issue was in the sx127x chip. After reset I put chip into the sleep mode. It was reporting that the sleep mode is active, but obviously it was not. After I changed sequence into:
  • go into sleep mode
  • then into standby mode
  • and finally back to sleep mode
Everything started working as expected.

Who is online

Users browsing this forum: iryna7 and 213 guests