Power Saving Mode (PSM) in NB-IoT: problems with reconnecting after deepsleep



  • Who can tell me how to implement Power Saving Mode (PSM) during deepsleep?

    I am testing the following script that emulates a measurement cycle of a device that needs to wake up, send data via NB-IoT and go into deepsleep without detaching from the network (to ensure the next cycle is short). I left out the commands for sending the data with the mqtt, and replaced it with a ping command, as that illustrates the problem well: if the deepsleep time is too long, the script cannot connect to a website altough lte.isattached and lte.isconnected are both True.

    from network import LTE
    from uping import ping
    import time, machine
    import config
    
    def send_at_cmd_pretty(cmd):
        response = lte.send_at_cmd(cmd).split('\r\n')
        for line in response:
            print(line)
    
    lte=LTE()
    
    lte.init()
    
    # attach to LTE network of Orange-Belgium
    lte.attach(band=config.BAND, apn=config.APN) 
    while not lte.isattached():
        time.sleep(0.25)
    
    lte.connect()  # start a data session and obtain an IP address
    while not lte.isconnected():
        time.sleep(0.25)
    
    # test if an internet site can be reached
    (packetsSent,packetsReceived)=ping('www.google.com')
    # if site cannot be reached, this will give OSError: [Errno 202] EAI_FAIL
    
    # at this point payload should be sent with mqtt
    
    lte.disconnect() # End the data session with the network
    
    # Swith off LTE modem to reduce power consumption to the minimum, but
    # don't detach from network and don't reset the modem to keep next cycle short
    lte.deinit(detach=False,reset=False) 
    # lte.detach(reset=False) # alternative that will detach modem from network
    
    sleepSeconds=10
    machine.deepsleep(sleepSeconds*1000) # time in ms
    

    This runs fine as long as the deepsleep time is only 30s or less. But when I make the deepsleep time 70s or longer, I cannot connect to the internet in the next cycle (with the ping command). In that case I get give OSError: [Errno 202] EAI_FAIL. That is what also happens with the mqtt commands if I use them.

    That problem can be avoided by doing a modem reset at the start of the script (lte.reset()). But attaching to the network then takes a lot of time. NB-IoT can only work for battery powered applications if the connection with the network is maintained.

    The time needed for a cycle is as follows:
    if no lte.reset() is used: 8.3s (0.0s for lte.init, + 0.3s for lte.attach + 1.3s for lte.connect + 6.6s for lte.disconnect + 0.1s for lte.deinit)
    if lte.reset() is used: 31.6s (6.0s for lte.reset + 0.0s for lte.init, + 17.6s for lte.attach + 1.3s for lte.connect + 6.6s for lte.disconnect + 0.1s for lte.deinit)

    What worries me also is that changing the options of lte.deinit(detach=False,reset=False) has no effect at all. My understanding from the documentation is that the choice 'detach=False' and 'reset=False' ensures that no time is lost with reconnecting to the network and with resetting the modem. And there seems to be no way to specify the TAU value, i.e., the time that the network needs to keep alive the connection with the device when the latter is in deepsleep with the modem switched off.

    By using the AT command +CPSM, I figured out that the TAU was set at 3 minutes (default?), and PSM was disabled. Enabling PSM and setting the TAU at several hours did not solve my problem and seems not to have any effect. That is strange, because I assumed PSM is implemented with the option lte.deinit(detach=False,reset=False). Power consumption during deepsleep drops to 22µA, which means the Sequans modem must be off. So the modem is correctly switched of, but the connection with the network cannot be maintained during deepsleep.

    I am using a gpy 1.0 with firmware 1.20.1.r2 and I updated the Sequans modem with NB1-41019.dup. I have a sim card from Orange-Belgium for NB-IoT and LTE-M, and sending/recieving data works as long as I don't use the deepsleep ...



  • @peterp I’m using the latest NB-IoT firmware 41019


  • Global Moderator

    @iot2020 said in Power Saving Mode (PSM) in NB-IoT: problems with reconnecting after deepsleep:

    @peterp
    I'm also getting the 20mA deep sleep current with the Pycom LTE class implementation while using PSM... Do you know what could be causing this? This is also the case with my own implementation, this is the last bump i'm running into with the modem...

    Yes, I've also seen this sometimes. Unfortunately, we have yet to find the root cause or a solution for it. Which modem firmware are you using?



  • @peterp
    I'm also getting the 20mA deep sleep current with the Pycom LTE class implementation while using PSM... Do you know what could be causing this? This is also the case with my own implementation, this is the last bump i'm running into with the modem...

    156b973b-c84f-4987-ba39-c3d4b6c07d34-image.png



  • I've got the PSM and eDRX working on LTE with help of the script by @peterp. I can confirm this because the modem is responding to pings from the network operator while a sleep. What i can't find out is how to wake the board after receiving an SMS. Without that the eDRX is quite useless. Is there anyone who can help me with this?



  • Power consumption without PSM (shutting the modem down after the active cycle:
    be226efa-c6a8-48fe-ab87-e0fe5a5f98a5-image.png
    Power consumption with PSM:
    e4527af2-338e-4391-ac7d-a247cfe78d55-image.png
    There is some paging going on after the data is send, this could be fixed by a socket with support for a release assistance flag.

    Power consumption with PSM and the force release command:

    PSM with release.png
    I do have a weird problem, the first cycle is kinda okay with a deepsleep power consumption of 200uA and later 20uA. In the following cycles this becomes 20mA.



  • @peterp I would, but the code is really messy right now... I'm also using this for my graduation project so I think I will share it with you after the project is done. I also have seem to find a AT! command that forces a release of the RRC connection... it is:

    AT!="RRC::forceConnectionRelease"
    

    It is kind of finicky to use because if you do it to early the data is not transferred... I'm really hoping there is going to be a socket implementation in the modem firmware with a RAI flag field... Like in the nordic, quectel and ublox modems...


  • Global Moderator

    @iot2020 said in Power Saving Mode (PSM) in NB-IoT: problems with reconnecting after deepsleep:

    I succeeded in enabling PSM by directly using the modem through UART. The connection is now stable.

    Would you be willing to share your implementation?



  • I succeeded in enabling PSM by directly using the modem through UART. The connection is now stable. The problem I have now is that there seems to be no support of a Release Assistance Indicator (RAI) flag when sending data with a socket. This causes the modem to wait for the provider to release the connection and to go in to PSM.

    When using CFUN=0 to shut the modem down after using the socket the complete cycle takes around 13,44 seconds with an avarage consumption of 104,59mA. If PSM is used the cycle takes around 31.65 seconds with an average power consumption of 117,78mA... This is very frustrating, because i'm trying to develop a solution that will use batteries...

    I believe other modems do support the RAI flag by using an AT+NSOSTF command where an extra flag for RAI could be added.



  • @agotsis I've had no luck with 41019 NB-IOT (with or without PSM) on the telstra network in Australia. My best battery life is catM1 (without psm) & deepsleeping between on air sessions, even though the attach/connect then disconnect/detach dance takes up 90% of each session.



  • @iot2020 @peterp I am also experiencing the same issues, after deep sleep. Actually RRC TOP FSM is either in disconnecting or in scanning state, but although AT+CEREG shows that the module is registered, any data transmission fails. I have also tried with the recent firmware 1.20.2.rc9 which includes PSM directives in the lte instatiation.



  • @peterp
    I'm getting the following output after deep sleep... Could it be waiting on something to confirm? Maybe that's the reason it isn't working

    Sent to modem: 'AT!="fsm"', delay 1000 ms
    SYSTEM FSM
    ==========
        +--------------------------+--------------------+
        |            FSM           |        STATE       |
        +--------------------------+--------------------+
        | RRC TOP FSM              |DISCONNECTING       |
        | RRC SEARCH FSM           |CAMPED              |
        | RRC ACTIVE FSM           |WAIT_REL_TIMER      |
        | PMM PLMN FSM             |NORM_CAMPED         |
        | EMM MAIN FSM             |REGISTERED          |
        | EMM AUTH FSM             |KASME_DEFINED       |
        | EMM CONN FSM             |EMM_RELEASING       |
        | EMM TAU FSM              |WAITING_TX_CONFIRM  |
        | EMM TEST FSM             |NULL                |
        | ESM BEARER FSM           |BEARER_ACTIVE       |
        | SMS MT FSM               |IDLE                |
        | SMS MO FSM               |IDLE                |
        | LPP FSM                  |IDLE                |
        | HP MAIN FSM              |IDLE                |
        | HP USIM FSM              |READY               |
        | HP SMS MO FSM            |IDLE                |
        | HP SMS MT FSM            |IDLE                |
        | HP CAT FSM               |IDLE                |
        +--------------------------+--------------------+
    


  • @peterp I'm trying with connecting after sleep, disconnecting and then reconnecting... Doesn't seem to change things :(

    Code snippet:

        print("PSM settings: {}".format(lte.psm()))
        print("Connecting")
        lte.connect()
        while not lte.isconnected():
            print(".", end="")
            utime.sleep(0.1)
    
        print("Disconnecting")
        lte.disconnect()
        while lte.isconnected():
            print(".", end="")
            utime.sleep(0.1)
    
        print("Connecting")
        lte.connect()
        while not lte.isconnected():
            print(".", end="")
            utime.sleep(0.1)
    
        print("Payload to be sent: ", payload)
        send(payload)
    

    Console output:

    PSM settings: (enabled=True, period_value=2, period_unit=1, active_value=1, active_unit=0)
    Connecting
    Disconnecting
    Connecting
    Payload to be sent:  022000000001ca
    

    I also notice that the IP address of the modem doesn't change after deep sleep attaching. It does change everytime when using the reset function after deepsleep. Maybe that could have something to do with it?

    I also tried changing the TAU and ACT values... also doesn't change anything.


  • Global Moderator

    Can you experiment with different tau and act values and check whether you can reconnect (something like lte.disconnect(); while lte.isconnected(): time.sleep(0.1); lte.connect() )



  • I'm experiencing the same issues. I use T-Mobile NL as NB-IoT provider. When I use PSM and go to deep sleep it attaches quickly after wakeup but the packets are not send (probably because there is no real connection). If I reset the modem first after deep sleep everything works as expected. So PSM works, i'm getting the values i propose. Quickly reattaching also seem to work. But there is no connection.

    I'm running firmware version 1.20.2.rc7 and modem firmware NB1-41019



  • @peterp When I run your code (with the only modification that I use "lte.attach(band=20, apn="att.iot") # for Orange, Belgium " it runs fine for the first cycle (when the module still needs to attach to the network which takes 16s). In the 2nd cycle (after a deepsleep) it is clear that the module is still attached to the network (so psm worked), but then I get an error "OSError: [Errno 202] EAI_FAIL" on line 35 in your code ("addr = socket.getaddrinfo(host, 80)[0][-1]"). That is exactly the same error that I got with my code when I tested whether I could connect to the internet in a second cycle.
    In your and my code I can avoid that error by doing a reset of the radio (lte.reset()) in the beginning. But that in fact forces the radio to attach to the network again (which takes 16s), so it means that we are then not taking advantage of psm.
    Please note that I run firmware 1.20.1.r2. If I upgrade to a more recent firmware, I can no longer connect through usb to my module because of this problem: link text


  • Global Moderator

    @kjm said in Power Saving Mode (PSM) in NB-IoT: problems with reconnecting after deepsleep:

    @peterp said in Power Saving Mode (PSM) in NB-IoT: problems with reconnecting after deepsleep:

    Also not that I also skip the lte.disconnect() - it is quite slow and seemingly not needed, deinit(detach=False,reset=False) works just fine.

    I have a non PSM related problem with a continuously attached/connected GPY with 43818 modem firmware. I get the socket problem OSError: [Errno 118] EHOSTUNREACH if I haven't contacted to the server for more than about half a minute. I find the only way to fix this is to disconnect then reconnect the modem. Wondering why deinit(detach=False,reset=False) does not work in this situation?

    Not sure. Please make a new forum post, otherwise it will get hard to stay on topic with any topic. If you can please include a minimal example that shows your reproduction.



  • @peterp said in Power Saving Mode (PSM) in NB-IoT: problems with reconnecting after deepsleep:

    Also not that I also skip the lte.disconnect() - it is quite slow and seemingly not needed, deinit(detach=False,reset=False) works just fine.

    I have a non PSM related problem with a continuously attached/connected GPY with 43818 modem firmware. I get the socket problem OSError: [Errno 118] EHOSTUNREACH if I haven't contacted to the server for more than about half a minute. I find the only way to fix this is to disconnect then reconnect the modem. Wondering why deinit(detach=False,reset=False) does not work in this situation?



  • @peterp said in Power Saving Mode (PSM) in NB-IoT: problems with reconnecting after deepsleep:

    @kjm From all I read, it should apply equally to NB-IoT and CAT-M1. I've only tested with NB-IoT.

    tnx. Do you have any comment on the difference in 41065 Vs 43818 firmware without PSM on continuously powered GPYs @ https://forum.pycom.io/topic/5802/lte-firmware-41065-vs-43818


  • Global Moderator

    @kjm said in Power Saving Mode (PSM) in NB-IoT: problems with reconnecting after deepsleep:

    I've been struggling with gpy lte issues surrounding attachment/connection for ages! I'm using CAT-M1 with 41065 or 43818 modem firmware.

    1. Peter, are the tau/act timers NB-IoT specific or are they relevant to CAT-M1 too?

    @kjm From all I read, it should apply equally to NB-IoT and CAT-M1. I've only tested with NB-IoT.

    1. Jan, I can't find the AT+CPSM cmd in the monarch LR5.1.1.0 manual? Is there a link that explains what this cmd does? It returns an error with my modem

    It's AT+CPSMS. It's in section 2.12 when you follow the link from here https://docs.pycom.io/datasheets/development/fipy/#at-commands


Log in to reply
 

Pycom on Twitter