Skip to content

SleepMode Lora Current #7

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

Open
kadirozdinc opened this issue May 4, 2023 · 8 comments
Open

SleepMode Lora Current #7

kadirozdinc opened this issue May 4, 2023 · 8 comments

Comments

@kadirozdinc
Copy link

kadirozdinc commented May 4, 2023

Firstly I tried lmic-otaa example with my setup, LoRa radio module (HopeRF RFM96) consumes 7.6uA all the time after sending packets. When trying your deepSleep codes everything works perferct ESP32-C3 consumes 5.6 uA but LoRa radio starts to consume approx. 67uA after sending packets. I realized that until esp32 go to sleep Lora consumes 7.6uA , After sleeping, currents goes up to 67uA.
I probe NSS RST DIO0 DIO1 pins and compare these two sketch, there is no difference between them. I could not find the reason. Do you have any idea about it ?

@cyberman54
Copy link

@kadirozdinc please post circuit diagram of you hardware. Without this it's not possible to pinpoint this.
You may also look at this working example how to control LMIC on a ESP32 system after wake up from sleep.

@cyberman54
Copy link

cyberman54 commented May 6, 2023

@kadirozdinc for debugging opmode of Hope RFM96 chip, add this build flag in platformio.ini:
-D LMIC_DEBUG_LEVEL=1

Then watch output on serial console. Look for LMIC opcode messages. Post result here to inspect.

Did you ensure having proper settings in lmic_config.h for your chip?
#define CFG_sx1272_radio vs. #define CFG_sx1276_radio

@cyberman54
Copy link

cyberman54 commented May 6, 2023

@kadirozdinc To inspect RFM95 chip mode when ESP32 goes to sleep, modify radio.c of LMIC:

static void opmode(u1_t mode) {
#if LMIC_DEBUG_LEVEL > 0
  LMIC_DEBUG_PRINTF("chip opmode=%d\n", mode);
#endif
  writeOpmode((readReg(RegOpMode) & ~OPMODE_MASK) | mode);
}

Then watch output "chip opmode=" logs on serial console. It should be 0 (= RFM95 sleep mode) when ESP32 goes to sleep. If not, the chip is not set to sleep mode before ESP32 goes to sleep. This would cause unnecessary power consumption during ESP32 sleeps.

@kadirozdinc
Copy link
Author

kadirozdinc commented May 8, 2023

I use esp32-c3-devkitC02 and HopeRF RFM96 Lora Radio module. Simply I connect SPI pins and other RST/NSS/DIO0/DIO1 pins on breadboard. I measure current going from 3V3 line to Vcc pin of Radio module.

I had made #define CFG_sx1272_radio vs. #define CFG_sx1276_radio changes in platformio.ini file

I modify opMode function as you mention above and add -D LMIC_DEBUG_LEVEL=1 code platformio.ini upload code into esp32. This time Device try to joing but noJoinAccept returns periodically somehow :/ Normally instantly can join successfully.

My Repo : https://github.com/kadirozdinc/esp32-c3-lmic/tree/deepSleepMode

Terminal outputs :

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x438
load:0x403cc710,len:0x91c
load:0x403ce710,len:0x25b0
entry 0x403cc710
Starting DeepSleep test
LMIC: 4.1.1.0
chip opmode=0
chip opmode=1
chip opmode=5
RXMODE_RSSI
chip opmode=0
chip opmode=0


LMIC.opmode:
LMIC.seqnoUp = 0
LMIC.globalDutyRate = 0 osTicks, 0 sec
LMIC.globalDutyAvail = 0 osTicks, 0 sec
LMICbandplan_nextTx = 1800019185 osTicks, 28800 sec
os_getTime = 19302 osTicks, 0 sec
LMIC.txend = 0
LMIC.txChnl = 0
Band    avail           avail_sec       lastchnl        txcap
0       0               0               0               0
1       0               0               0               0
2       0               0               0               0
3       0               0               0               0


20787: engineUpdate, opmode=0x8
Packet queued
21026: EV_JOINING
21098: engineUpdate, opmode=0xc
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 2 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 4 seconds
307627: engineUpdate, opmode=0xc
308050: EV_TXSTART
chip opmode=1
chip opmode=3
309030: TXMODE, freq=868100000, len=23, SF=7, BW=125, CR=4/5, IH=0
chip opmode=0
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA OP_TXRXPEND OP_NEXTCHNL Runtime: 6 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA OP_TXRXPEND OP_NEXTCHNL Runtime: 8 seconds
chip opmode=1
chip opmode=6
start single rx: now-rxtime: 207
625555: RXMODE_SINGLE, freq=868100000, SF=7, BW=125, CR=4/5, IH=0
Cannot sleep TimeCriticalJobs: 0 LMIC.opmode: OP_JOINING OP_TXDATA OP_TXRXPEND OP_NEXTCHNL Runtime: 10 seconds
rxtimeout: entry: 626603 rxtime: 625261 entry-rxtime: 1342 now-entry: 59 rxtime-txend: 312375       
chip opmode=0
chip opmode=1
chip opmode=6
start single rx: now-rxtime: 166
688014: RXMODE_SINGLE, freq=869525000, SF=12, BW=125, CR=4/5, IH=0
rxtimeout: entry: 702278 rxtime: 687761 entry-rxtime: 14517 now-entry: 53 rxtime-txend: 374875
chip opmode=0
702724: EV_JOIN_TXCOMPLETE: no JoinAccept
702848: engineUpdate, opmode=0xc
Cannot sleep TimeCriticalJobs: 0 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 12 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 14 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 16 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 18 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 20 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 22 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 24 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 26 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 28 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 30 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 32 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 34 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 36 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 38 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 40 seconds


After waiting some more time, TX is complated, terminal is like :

Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 208 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 210 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 212 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA Runtime: 214 seconds
13459012: engineUpdate, opmode=0xc
13459435: EV_TXSTART
chip opmode=1
chip opmode=3
13460406: TXMODE, freq=868500000, len=23, SF=8, BW=125, CR=4/5, IH=0
chip opmode=0
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA OP_TXRXPEND OP_NEXTCHNL Runtime: 216 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA OP_TXRXPEND OP_NEXTCHNL Runtime: 218 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_JOINING OP_TXDATA OP_TXRXPEND OP_NEXTCHNL Runtime: 220 seconds
chip opmode=1
chip opmode=6
start single rx: now-rxtime: 189
13780140: RXMODE_SINGLE, freq=868500000, SF=8, BW=125, CR=4/5, IH=0
chip opmode=0
13789449: EV_JOINED
netid: 19
devaddr: 260BB1A1
artKey: EC32DDE1E1C58C979E3F735D5CBFC9
nwkKey: C76D695D8B4FF66B5E757CF7A80416
13790182: engineUpdate, opmode=0x808
13790741: EV_TXSTART
chip opmode=1
chip opmode=3
13791689: TXMODE, freq=868100000, len=17, SF=8, BW=125, CR=4/5, IH=0
chip opmode=0
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_TXDATA OP_TXRXPEND OP_NEXTCHNL Runtime: 222 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_TXDATA OP_TXRXPEND OP_NEXTCHNL Runtime: 224 seconds
chip opmode=1
chip opmode=6
start single rx: now-rxtime: 202
14110159: RXMODE_SINGLE, freq=868100000, SF=8, BW=125, CR=4/5, IH=0
chip opmode=0
14116478: Received downlink, window=RX1, port=-1, ack=0, txrxFlags=0x21
14116688: EV_TXCOMPLETE (includes waiting for RX windows)
14116788: engineUpdate, opmode=0x910
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_POLL OP_RNDTX Runtime: 226 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_POLL OP_RNDTX Runtime: 228 seconds
14368908: engineUpdate, opmode=0x110
14369346: EV_TXSTART
chip opmode=1
chip opmode=3
14370277: TXMODE, freq=868300000, len=14, SF=7, BW=125, CR=4/5, IH=0
chip opmode=0
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_TXRXPEND OP_NEXTCHNL Runtime: 230 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_TXRXPEND OP_NEXTCHNL Runtime: 232 seconds
Cannot sleep TimeCriticalJobs: 1 LMIC.opmode: OP_TXRXPEND OP_NEXTCHNL Runtime: 234 seconds
chip opmode=1
chip opmode=6
start single rx: now-rxtime: 203
14685850: RXMODE_SINGLE, freq=868300000, SF=7, BW=125, CR=4/5, IH=0
rxtimeout: entry: 14686286 rxtime: 14685555 entry-rxtime: 731 now-entry: 58 rxtime-txend: 312375
chip opmode=0
chip opmode=1
chip opmode=6
start single rx: now-rxtime: 157
14748298: RXMODE_SINGLE, freq=869525000, SF=9, BW=125, CR=4/5, IH=0
rxtimeout: entry: 14750017 rxtime: 14748055 entry-rxtime: 1962 now-entry: 57 rxtime-txend: 374875
chip opmode=0
14750487: EV_TXCOMPLETE (includes waiting for RX windows)
14750573: engineUpdate, opmode=0x900
Can go sleep LMIC.opmode: OP_RNDTX OP_NEXTCHNL Save LMIC to RTC
Reset CFG_LMIC_EU_like band avail
Go DeepSleep
Runtime: 236 seconds

Current consumption still about 300uA when sleeping

Ekran görüntüsü 2023-05-08 142140

@cyberman54
Copy link

The debug log shows, that Lora Chip is in sleep mode, before esp32 goes in sleep mode. That's how it should work.

While in sleep mode the chip is still drawing current, please try to disable SPI interface by pulling some wires from breadboard. Then check if current persists. Start with pulling SS line. Then SCLK. Then MISO/MOSI.

@kadirozdinc
Copy link
Author

kadirozdinc commented May 9, 2023

When I pull these wires from breadboard respectively current drawn increased. This time I use esp32d dev board instead of C3 model. When sleeping, current drawn was approximately 84uA
When pulling SS goes up to 237uA
When pulling SCK goes down to 218uA

There seems to be something floating after sleeping. Current drawn is not stable all the time after a while a little bit goes up or down somehow.

Did you look over my repo ? firstly I suspect radio module and esp32, I set up 2 different circuit but nothing changed. Here is my setups:
setup

@cyberman54
Copy link

Are you sure that in your setup the current drawn by the Lora chip is measured, ONLY? I.e. not the current drawn by pullup/pulldown resistors on digital lines, etc.? Can you provide a circuit diagram of your setup?

To make sure we have no false positive.

@kadirozdinc
Copy link
Author

kadirozdinc commented May 15, 2023

I measure current from 3V3 to VCC pin of radio module. ESP32 module has pullup resistors on itself to be able to boot and work correctly. System is suplied by usb port of esp32dev module. ı made some minor changes in pin definition. Circuit Diagram is below :

ss1

Did you measure current I mentioned in your own setup ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants