dormancy dilemma

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
KJM
Posts: 158
Joined: Sun Nov 18, 2018 10:53 pm
Location: Sydney AU

dormancy dilemma

Post by KJM » Tue Dec 07, 2021 1:55 am

I'm using an rpi pico with an NB-IoT cell modem https://www.waveshare.com/w/upload/c/c2 ... NB-IoT.pdf  The pico-modem interface is simple, just a uart connection for AT cmds & a single gpio line to turn the modem power supply on/off

My initial program worked 

Code: Select all

while 1:    
    modem on 
    check modem is attached to cellular
    connect to cellular
    upload data
    modem off
    time.sleep(600)
 
Then I tried to get clever by replacing the sleep with dormant https://github.com/ghubcoder/PicoSleepD ... -945177298 for lower power consumption.  Now the connect to cell AT cmd fails after the first cycle. This was a big surprise since the pico-to-modem uart comms & gpio pwr on/off line post dormancy behave exactly the same as post sleep.

Code: Select all

while 1:    
    modem on
    check modem is attached to cellular
    connect to cellular
    upload data
    modem off
    picosleep.seconds(600)

I finally got it going with a kludgy work around. I've got my 1mA dormancy Vs 18mA sleep but there are 2 things I don't understand, why the AT connect cmd fails after a dormancy & why resetting the pico post dormancy fixes it.

Code: Select all

modem on
check modem is attached to cellular
connect to cellular
upload data
modem off
picosleep.seconds(600)
machine.reset()

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: dormancy dilemma

Post by pythoncoder » Tue Dec 07, 2021 9:55 am

From your description it would seem that after the dormant period the Pico can communicate with the modem. The fact that failure occurs on the connect to cell command suggests it may be a power problem on the modem board which will suddenly require a lot more power. The schematic is pretty illegible so it's hard to be sure, but maybe the modem power supply isn't re-initialising properly.

FWIW my experience with Waveshare hardware is dire. Two display units bought from different suppliers each with different hardware faults.
Peter Hinch
Index to my micropython libraries.

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: dormancy dilemma

Post by scruss » Tue Dec 07, 2021 5:14 pm

A Sim7020E can pull over 130 mA when connecting to a weak LTE signal. I'm wondering if dormant is doing any power supply tricks, such as toggling the on-board SMPS Power Save pin.

KJM
Posts: 158
Joined: Sun Nov 18, 2018 10:53 pm
Location: Sydney AU

Re: dormancy dilemma

Post by KJM » Thu Dec 09, 2021 12:34 am

Thnx for the input fellas. I ditched the waveshare, got a new pico & wired it's uart to a sim7020e breakout board which I powered separately to the pico (which is still powered from the USB). So now when the pico goes dormant the modem stays powered. On the second run of the program the modem connect cmd again fails so I figure the problem has to be something to do with the uart even though I can't see any difference on the pico uart Tx line with a DSO.

I really expected the modem to remain connected after the first dormancy so how the uart activity during or after the first dormancy is disconnecting it (& why the machine.reset() prevents it happening) has got me beat. I guess put the machine.reset() back in after the dormancy & learn to live with it.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: dormancy dilemma

Post by pythoncoder » Thu Dec 09, 2021 11:12 am

That sounds very odd indeed. You've got me stumped :(
Peter Hinch
Index to my micropython libraries.

KJM
Posts: 158
Joined: Sun Nov 18, 2018 10:53 pm
Location: Sydney AU

Re: dormancy dilemma

Post by KJM » Thu Dec 09, 2021 10:55 pm

Doesn't make any sense eh Peter. Guess I should be grateful the bug remains stable with a change of hardware.

KJM
Posts: 158
Joined: Sun Nov 18, 2018 10:53 pm
Location: Sydney AU

Re: dormancy dilemma

Post by KJM » Sat Dec 11, 2021 1:13 am

I finally got to the bottom of this. The dormancy leaves the pico with a uart unable to send or receive more than 32 chrs. So when the modem returns
b'at+cgcontrdp\r\r\n+CGCONTRDP: 1,5,"telstra.internet","10.108.59.111.255.255.255.0",,"101.168.244.106","10.4.130.164",,,,,1500 for the connect cmd the pico sees only
b'at+cgcontrdp\r\r\n+CGCONTRDP: 1,5,

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: dormancy dilemma

Post by pythoncoder » Sat Dec 11, 2021 9:23 am

Good bit of detective work. I suggest producing a simple test case and raising an issue.
Peter Hinch
Index to my micropython libraries.

Post Reply