FiPy LTE Not Initialized

  • I have a FiPy that is connecting to the lte network but after a few hours of running i will get the following error.

    [ 71998.935] MQTT published packets: 1
    [ 71999.936] MQTT published packets: 1
    [ 72000.937] MQTT published packets: 1
    [ 72001.934] MQTT published packets: 1
    [ 72002.935] MQTT published packets: 1
    [ 72003.937] MQTT published packets: 1
    [ 72004.933] MQTT published packets: 1
    [ 72005.935] MQTT published packets: 1
    [ 72006.936] MQTT published packets: 1
    [ 73074.841] MQTT publish error: [Errno 113] ECONNABORTED
    [ 73074.851] MQTT published packets: 1
    [ 73089.333] MQTT connect error: [Errno 202] EAI_FAIL
    [ 73089.342] LTE disconnecting...
    [ 73112.411] LTE disconnected
    Traceback (most recent call last):
    File "", line 1, in <module>
    File "", line 152, in <module>
    File "", line 152, in <module>
    File "/flash/lib/", line 58, in reconnect
    File "/flash/lib/", line 82, in _start
    File "/flash/lib/", line 26, in _attach
    OSError: LTE modem not initialized
    Pycom MicroPython 1.20.2.r0 [v1.11-783192e] on 2020-08-06; FiPy with ESP32

    My program is publishing data to our mqtt broker and then I get an aborted error from the broker so I close the mqtt connection and try to reconnect leaving the lte connection alone. When I call the mqtt connect, I get error 202. So I am assuming this is a network error. I then disconnect the lte modem and then reconnect but I get the error "LTE modem not initialized". Is this caused by resetting the modem during the deinit? Here is my lte code.

    from network import LTE
    import utime
    import _thread
    from debug import log
    from constants import const
    class lte:
        def __init__(self, reset=False):
            self.lte = LTE(carrier=const.LTE_CARRIER, cid=const.LTE_CID)
            self.connected = False
            self.reset = reset
            if self.reset:
            self.lte.lte_callback(LTE.EVENT_COVERAGE_LOSS, self._lte_cb)
            # _thread.start_new_thread(self._start, ())
        def _lte_cb(self, lte):
            log('LTE coverage lost')
        def _attach(self):
            if not self.lte.isattached():
                    self.lte.attach(band=const.LTE_BAND, cid=const.LTE_CID, apn=const.LTE_APN)
                    log('LTE attaching...')
                    while not self.lte.isattached():
                    log('LTE attached')
                except Exception as ex:
                    log('LTE attach error: {}', ex)
        def _connect(self):
            if self.lte.isattached():
                    log('LTE connecting...')
                    while not self.isconnected():
                    log('LTE connected')
                    return True
                except Exception as ex:
                    log('LTE connect error: {}', ex)
                log('LTE cannot connect because it is not attached')
                return False
        def reconnect(self):
            if self.connected:
                log('LTE disconnecting...')
                log('LTE disconnected')
                self.connected = False
                # _thread.start_new_thread(self._start, ())
        def isconnected(self):
            return self.lte.isconnected()
        def rssi(self):
            if self.isconnected():
            rssi = int(self.lte.send_at_cmd('AT+CSQ').split('\r\n')[1].split(' ')[1].split(',')[0])
            if self.isconnected():
            if rssi is 99:
                return rssi
                return (rssi * 2) - 113
        def send_at_cmd_pretty(self, cmd):
            response = self.lte.send_at_cmd(cmd).split('\r\n')
            for line in response:
                log('{}', line)
        def _start(self):
            while not self.connected:
                # self.lte.init(carrier=const.LTE_CARRIER)
                if self._connect():
                    self.connected = True

  • @kjm Thank you for the response. You are right about the deint. I made a test program that would go through the steps to connect over lte, then get the address of a server to verify connection, and then call my reconnect logic. I could duplicate the same error so I added the init function call just before the attach and now it works.

  • @ssummers In answer to your question, it's not the reset causing the 'not initialised' error it's the denit itself, you have disposed of the lte so you need to make a new one, lte=LTE() Re network disconnections, I've never had any luck with getting the sequans to reconnect on an existing attachment.

    My experience in marginal RF environments is that the modem actually looses attachment but doesn't know it, lte.isattached() and lte.isconnected() are both true but trying lte.disconnect() throws an OSError. I call this ZombiModem mode & the the only fix is to reset the modem & setup a new lte/attachment/connection.

  • Global Moderator

    We've seen more examples of the LTE connection dropping after some period. While this is not desirable, it is inevitable, as the RF link is highly variable etc.) It should of course be recoverabl. One thing to do is indeed the lte.reset(), you can add parameter debug=True to get more information about the communication between the modem and microcontroller. It should also be possible to hard reset the modem in the last case you mentioned, altough at the moment Im not exactly sure how without hardware modifications


  • I forgot to add the following:

    FiPy with firmware version 1.20.2.r0
    Your modem is in application mode. Here is the current version:

Log in to reply

Pycom on Twitter