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:
    # attach to LTE network of Orange-Belgium
    lte.attach(band=config.BAND, apn=config.APN) 
    while not lte.isattached():
    lte.connect()  # start a data session and obtain an IP address
    while not lte.isconnected():
    # test if an internet site can be reached
    # 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.detach(reset=False) # alternative that will detach modem from network
    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 ...

  • A correction to what I wrote previously: I found that lte.deinit(detach=False, reset=False) followed by a deepsleep does not do what it is supposed to do: power consumption during deepsleep still varies between 27-90mA instead of the typical deepsleep power consumption of 22µA. This is not is line with the statement "lte.deinit(dettach=False) allows the modem to go into power saving mode (PSM, eDRX) without dettaching from the network." as posted here: New LTE Firmware release v1.18.1.r3 & CAT-M1 firmware. So the only thing that works for me is ending with lte.deinit(). If that is done, no reset is needed at the start of the next cycle, and re-connection is established reliably. But it takes time (with the lte.attach(... step taking typically 10s, and the total cycle (lte.init, lte.attach, lte.connect, lte.disconnect, lte.deinit, deepsleep) taking about 20-24s.

    Am I correct that this means that it is not yet possible to switch off the modem completely during deepsleep without detaching from the network (PSM)? Or who managed to do this? How?

Log in to reply

Pycom on Twitter