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:
- SPI.begin(SCK, MISO, MOSI, SS);
- LoRa.begin(BAND, false)
- LoRa.sleep();
- SPI.end();
- pinMode(14, INPUT);
- pinMode(SCK, INPUT);
- pinMode(MISO, INPUT);
- pinMode(MOSI, INPUT);
- pinMode(SS, INPUT);
- pinMode(15, INPUT);
- pinMode(16, INPUT);
- pinMode(17, INPUT);
- pinMode(26, INPUT);
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