Trying to connect to LTE-M1



  • I am trying to connect to the local KPN network. I found two networks in my area on band 20. KPN and Vodafone. I have a KPN-sim, so i tried to set the code to KPN with AT+COPS:2 etc. But when i try lte.isattach() it constantly give False. I tried to force register to a network with 'AT+COPS=1,2,"20408"' but this gives an error. Also the forced network disappears from the found networks in the erea. As far as i know KPN network is supported, it is also listed in 'AT+COPN'. The output can be find in the comments. I have tried waiting for 5-10 min with a while loop after the attach, but still no attaching happening.

    Who could help me out, to connect?

    from network import LTE
    import pycom
    import time
    
    lte = LTE()
    
    def send_at_cmd_pretty(cmd):
        response = lte.send_at_cmd(cmd).split('\r\n')
        for line in response:
            print(line)
    
    
    print("LTE-M1 procedure")
    #print("NB-IoT procedure")
    #send_at_cmd_pretty('ATZ') # Reset to default config
    #send_at_cmd_pretty('AT&F') # Reset to factory config
    #time.sleep(5)
    
    print("Resetting to factory config...", end='')
    send_at_cmd_pretty('AT^RESET') # Hard reset
    time.sleep(5)
    
    print("FSM status 1 ", end='')
    send_at_cmd_pretty('AT!="fsm"') # OK
    time.sleep(5)
    
    print('Status 1:')
    send_at_cmd_pretty('AT!="showphy"') # OK
    time.sleep(5)
    
    print("RF off mode / Low power... ", end='')
    send_at_cmd_pretty('AT+CFUN=0') # OK
    time.sleep(5)
    
    print("Clear scan configuration...", end='')
    send_at_cmd_pretty('AT!="clearscanconfig"') # OK
    time.sleep(5)
    
    print("Add band 20 to scan...", end='')
    send_at_cmd_pretty('AT!="addscanband band=20"') # OK
    time.sleep(5)
    
    print("Disable log 1....", end='')
    send_at_cmd_pretty('AT!="disablelog 1"') # OK
    time.sleep(5)
    
    print("Config of the LTE APN...", end='')
    send_at_cmd_pretty('AT+CGDCONT=1,"IP","item.internet.m2m"') # OK 
    #send_at_cmd_pretty('AT+CGDCONT=1,"IP","Item.webtrail.m2m"')  
    #send_at_cmd_pretty('AT+CGDCONT=1,"IP","Internet.m2m"') 
    #send_at_cmd_pretty('AT+CGDCONT=1,"IP","M2MC.WEBTRAIL"') 
    time.sleep(5)
    
    #print("Instellen van NB-IoT APN...", end='')
    #send_at_cmd_pretty('AT+CGDCONT=1,"IP","c.dpiot.t-mobile.nl"')
    #time.sleep(5)
    
    print("Add scanfreq band en dl-earfcn...", end='')
    send_at_cmd_pretty('AT!="RRC::addscanfreq band=20 dl-earfcn=6300"') # scan band 20/6240 of band 8/3650 of band 28/9410
    time.sleep(5)
    
    print("Turn module to full functionality...", end='')
    send_at_cmd_pretty('AT+CFUN=1') # OK
    print("wait 30 sec")
    time.sleep(5)
    print("wait 25 sec")
    time.sleep(5)
    print("wait 20 sec")
    time.sleep(5)
    print("wait 15 sec")
    time.sleep(5)
    print("wait 10 sec")
    time.sleep(5)
    print("wait  5 sec")
    time.sleep(5)
    
    print("FSM status 2 ", end='')
    send_at_cmd_pretty('AT!="fsm"') # OK
    time.sleep(5)
    
    print("Show list with networks...", end='')
    send_at_cmd_pretty('AT+COPS=?') # +COPS: (2,"NL KPN","NL KPN","20408",7)(1,"vodafone NL","voda NL","20404",7),,(0,1,2,3,4),(0,1,2)
    print("wait 30 sec")
    time.sleep(5)
    print("wait 25 sec")
    time.sleep(5)
    print("wait 20 sec")
    time.sleep(5)
    print("wait 15 sec")
    time.sleep(5)
    print("wait 10 sec")
    time.sleep(5)
    print("wait  5 sec")
    time.sleep(5)
    
    print("Current network...", end='') 
    send_at_cmd_pretty('AT+COPS?') #  +COPS: 1 
    time.sleep(5)
    
    print("Config to network 2: KPN", end='') # i want +COPS: 2 KPN
    send_at_cmd_pretty('AT+COPS=2') 
    time.sleep(5)
    
    print("Current network...", end='')
    send_at_cmd_pretty('AT+COPS?') #  +COPS: 2
    time.sleep(5)
    
    print("LTE attach functie... ", end='')
    lte.attach(band=20) # poging tot verbinden, soms nodig, doet iets intern, beetje vaag
    print("OK")
    print("wait 30 sec")
    time.sleep(5)
    print("wait 25 sec")
    time.sleep(5)
    print("wait 20 sec")
    time.sleep(5)
    print("wait 15 sec")
    time.sleep(5)
    print("wait 10 sec")
    time.sleep(5)
    print("wait  5 sec")
    time.sleep(5)
    
    print("Error report...", end='')
    send_at_cmd_pretty('AT+CEER') # +CEER: lastEmmCause: NO CAUSE RECEIVED, lastEsmCause: NO CAUSE RECEIVED
    time.sleep(5)
    
    print('Status 2:')
    send_at_cmd_pretty('AT!="showphy"') # OK
    time.sleep(5)
    
    print("FSM status 3 ", end='')
    send_at_cmd_pretty('AT!="fsm"') # OK
    time.sleep(5)
    
    print("Force register to network...", end='') # ERROR, also the forced network disappears from list
    #send_at_cmd_pretty('AT+COPS=1,2,"20408"') # force select and register network, connect with KPN
    #send_at_cmd_pretty('AT+COPS=1,2,"20416"') # force select and register network, connect with T-Mobile
    print("wacht 30 sec")
    time.sleep(5)
    print("wacht 25 sec")
    time.sleep(5)
    print("wacht 20 sec")
    time.sleep(5)
    print("wacht 15 sec")
    time.sleep(5)
    print("wacht 10 sec")
    time.sleep(5)
    print("wacht  5 sec")
    time.sleep(5)
    
    print("FSM status 4 ", end='')
    send_at_cmd_pretty('AT!="fsm"') # OK
    time.sleep(5)
    
    print("Check signal strength...", end='')
    send_at_cmd_pretty('AT+CSQ') # +CSQ: 24,99 OK
    time.sleep(5)
    
    print("Connected?...", end='') # +CGATT: 0
    send_at_cmd_pretty('AT+CGATT?')
    time.sleep(5)
    
    print("Show IP adres:...", end='') 
    send_at_cmd_pretty('AT+CGPADDR') # +CGPADDR: 1   +CGPADDR: 2
    time.sleep(5)
    
    print('Status 3:')
    send_at_cmd_pretty('AT!="showphy"') # OK
    time.sleep(5)
    
    print("FSM status 5 ", end='')
    send_at_cmd_pretty('AT!="fsm"') # OK
    time.sleep(5)
    
    #lte.deinit()
    print('Finished')
    
    #send_at_cmd_pretty('AT+COPN') # List operators names
    # LTE/NB: +COPN: "20408","NL KPN"
    #               "20416","T-Mobile" 
    
    


  • Hi,

    After upgrading im no longer able to attach. Im not able to find a solution and also not able to find how to return to stock modem firmware.

    ###CODE
    from network import LTE
    lte = LTE(carrier="at&t")
    lte.attach(band=4)
    def pretty(cmd):
    response = lte.send_at_cmd(cmd).split('\r\n')
    for line in response:
    print(line)

    #Troubleshooting

    ###get the System FSM
    AT!="fsm"

    SYSTEM FSM

    +--------------------------+--------------------+
    |            FSM           |        STATE       |
    +--------------------------+--------------------+
    | RRC TOP FSM              |CAMPED              |
    | RRC SEARCH FSM           |CAMPED_ANY          |
    | RRC ACTIVE FSM           |IDLE                |
    | PMM PLMN FSM             |ANY_CAMPED          |
    | EMM MAIN FSM             |NULL                |
    | EMM AUTH FSM             |NULL                |
    | EMM CONN FSM             |NULL                |
    | EMM TAU FSM              |NULL                |
    | EMM TEST FSM             |NULL                |
    | ESM BEARER FSM           |BEARER_NULL         |
    | SMS MT FSM               |IDLE                |
    | SMS MO FSM               |IDLE                |
    | HP MAIN FSM              |IDLE                |
    | HP USIM FSM              |ABSENT              |
    | HP SMS MO FSM            |IDLE                |
    | HP SMS MT FSM            |IDLE                |
    | HP CAT FSM               |NULL                |
    +--------------------------+--------------------+
    

    ###Fet the PHY status
    AT!="showphy"

    DL SYNCHRO STATISTICS

    Synchro state                         : DRX_SLEEP
    PPU SIB1 ACQ watchdog                 : 0
    Frequency Hypothesis RF  (Hz)         : 0
    RSRP (dBm)                            : -98.70
    RSRQ  (dB)                            : -13.89
    Channel estimation state (Cell-spec.) : LOW CINR
    Channel estimation state (UE-spec.)   : LOW CINR
    Channel estimation state (MBSFN)      : LOW CINR
    Channel estimation CINR               : 1.77
    Channel length                        : SHORT
    

    AGC
    AGC RX gain (dB) : 55.16
    RX PSD BO (dBFs) : -20.15
    RX PSD (dBm) : -101.62
    Noise level RS (dBm) : -101.98
    Digital gain (dB) : 9.87
    CINR RS (dB) : 3.28
    NARROWBANDS
    Last DL NB : Central
    Last UL NB : 0
    AFC
    Frequency offset RF (Hz) : -1323
    Frequency offset BB (Hz) : 0
    PBCH
    MIB received quantity : 14
    MIB timeout quantity : 0

    International Mobile Subscriber Identity

    AT+CIMI=?
    Error

    ###Signal quality
    AT+CSQ
    +CSQ: 15,99

    PDP Context

    AT+CGDCONT?
    +CGDCONT: 1,"IP","web.iusacellgsm.mx",,,,0,0,0,0,0,0

    ###Network Registration
    AT+CREG?
    +CREG: 0,0

    ###Software Version
    ATI1
    UE5.0.0.0d
    LR5.1.1.0-38638

    ###ATC Cell Monitoring
    #Supported values
    AT+SQNMONI=?
    #Report from all cells
    AT+SQNMONI=7
    +SQNMONI: TELCEL Cc:334 Nc:020 RSRP:-1 RSRQ:-1 TAC:23330 Id:235 EARFCN:2050 PWR:-1 PAGING:128
    +SQNMONI: TELCEL Cc:334 Nc:020 RSRP:-1 CINR:-1 RSRQ:-1 TAC:23330 Id:235 EARFCN:2050 PWR:-1 PAGING:128

    ###ICCID (card identification number) on the SIM card.
    AT+SQNCCID
    SQNCCID: "",""

    ###Conformance Test Mode
    AT+SQNCTM?
    +SQNCTM: standard



  • @optionseven I tried your code, result below. And yes, i updated tot 1.18.1.R1 (latest) and installed the catm1.dup again. So i started with a fresh install.

    Configure PDP Context 1:
    
    OK
    
    Turning on modem
    
    OK
    
    
    +COPS: (2,"NL KPN","NL KPN","20408",7)(1,"vodafone NL","voda NL","20404",7),,(0,1,2,3,4),(0,1,2)
    
    OK
    
    Registering manually to KPN network:
    
    ERROR
    
    +CEREG: 2
    
    Checking which network the modem is registered to
    
    +COPS: 1
    
    OK
    
    Attaching to LTE network ..............
    

    Version of modem:

    SYSTEM VERSION

    FIRMWARE VERSION
    Bootloader0 : 5.1.1.0 [33080]
    Bootloader1* : 5.1.1.0 [38638]
    Bootloader2 : 5.1.1.0 [38638]
    NV Info : 1.1,0,0
    Software : 5.1.1.0 [38638] by robot-soft at 2018-08-20 09:51:46
    UE : 5.0.0.0d
    COMPONENTS
    ZSP0 : 1.0.99-13604
    ZSP1 : 1.0.99-12341



  • @chielvdiepen are you certain the modem firmware running is CATM1-38638.dup?

    Here is my code:

    import socket
    import ssl
    import time
    from network import LTE
    
    def pretty(cmd):
        response = lte.send_at_cmd(cmd).split('\r\n')
        for line in response:
            print(line)
    
    lte = LTE()         # instantiate the LTE object
    
    print("Resetting modem:")
    pretty('AT^RESET')
    pretty('AT!="fsm"')
    time.sleep(5)
    # DL SYNCHRO STATISTICS
    pretty('AT!="showphy"')
    time.sleep(5)
    print("Turning off antenna:")
    pretty('AT+CFUN=0')
    time.sleep(5)
    print("Clearing scanning configuration:")
    pretty('AT!="clearscanconfig"')
    time.sleep(5)
    print("Adding scan frequency for band 20")
    pretty('AT!="RRC::addScanBand band=20"')
    pretty('AT!="disablelog 1"')
    time.sleep(5)
    print("Configure PDP Context 1:")
    pretty('AT+CGDCONT=1,"IP","ltem.webtrial.m2m"')
    time.sleep(5)
    print("Turning on modem")
    pretty('AT+CFUN=1')
    time.sleep(15)
    print("Registering manually to KPN network:")
    pretty('AT+COPS=1,2,"20408"')
    time.sleep(5)
    print("Checking which network the modem is registered to")
    pretty('AT+COPS?')
    time.sleep(5)
    
    # If correctly configured for carrier network, attach() should succeed.
    if not lte.isattached():
        print("Attaching to LTE network ", end='')
        lte.attach()
        while(True):
            if lte.isattached():
                print(" OK")
                break
            print('.', end='')
            time.sleep(1)
    
    # Once attached, connect() should succeed.
    if not lte.isconnected():
        print("Connecting on LTE network ", end='')
        lte.connect()
        while(True):
            if lte.isconnected():
                print(" OK")
                break
            print('.', end='')
            time.sleep(1)
    
    s = socket.socket()
    s = ssl.wrap_socket(s)
    s.connect(socket.getaddrinfo('www.google.com', 443)[0][-1])
    s.send(b"GET / HTTP/1.0\r\n\r\n")
    print(s.recv(4096))
    s.close()
    


  • @optionseven When i tried your suggestion code with my code, it gave me an error at ('AT+COPS=1,2,"20408"'). Dont understand why it is working for you. Could you maybe show me your code?

    Show list with networks...
    +COPS: (2,"NL KPN","NL KPN","20408",7)(1,"vodafone NL","voda NL","20404",7),,(0,1,2,3,4),(0,1,2)
    
    OK
    
    wait 10 sec
    wait  5 sec
    Current network...
    +COPS: 1
    
    OK
    
    Config to network 2: KPN
    ERROR
    
    


  • @ChielvDiepen We just managed to connect to the KPN LTE-M1 network. Try replacing the following AT-commands:
    OLD:

    send_at_cmd_pretty('AT!="addscanband band=20"')
    

    NEW:

    send_at_cmd_pretty('AT!="RRC::addScanBand band=20"')
    

    OLD:

    send_at_cmd_pretty('AT+CGDCONT=1,"IP","item.internet.m2m"')
    

    NEW (notice the typo: ITEM should be LTEM) :

    send_at_cmd_pretty('AT+CGDCONT=1,"IP","ltem.internet.m2m"')
    

    OR (this is the APN we use):

    send_at_cmd_pretty('AT+CGDCONT=1,"IP","ltem.webtrial.m2m"')
    

    REMOVE (we didn't need it):

    send_at_cmd_pretty('AT!="RRC::addscanfreq band=20 dl-earfcn=6300"')
    

    OLD:

    send_at_cmd_pretty('AT+COPS=2')
    

    NEW:

    send_at_cmd_pretty('AT+COPS=1,2,"20408"')
    

    The xykon firmware is not necessary, this works for us with 1.18.1.r1

    Last but crucial in our case was to upgrade the modem firmware to CAT-M1. Upgrading to NB-IoT overwrites the CAT-M1 firmware and then lte.attach() will not work with the commands above.



  • @robert-hh unfortunately the new software version is not working, but still thank you for the quick reply.



  • This is my output of SHOWPHY:

    DL SYNCHRO STATISTICS
    =====================
        Synchro state                         : DRX_SLEEP
        PPU SIB1 ACQ watchdog                 : 0
        Frequency Hypothesis RF  (Hz)         : 0
        RSRP (dBm)                            : -76.29
        RSRQ  (dB)                            : -7.05
        Channel estimation state (Cell-spec.) : HIGH CINR
        Channel estimation state (UE-spec.)   : LOW CINR
        Channel estimation state (MBSFN)      : LOW CINR
        Channel estimation CINR               : 28.63
        Channel length                        : SHORT
      AGC
        AGC RX gain (dB)                      : 38.58
        RX PSD BO (dBFs)                      : -22.12
        RX PSD (dBm)                          : -80.21
        Noise level RS (dBm)                  : -100.75
        Digital gain (dB)                     : 5.04
        CINR RS (dB)                          : 24.46
      NARROWBANDS
        Last DL NB                            : Central
        Last UL NB                            : 0
      AFC
        Frequency offset RF  (Hz)             : -362
        Frequency offset BB  (Hz)             : 0
      PBCH
        MIB received quantity                 : 91
        MIB timeout quantity                  : 0
    
    OK
    

    And FSM:

    SYSTEM FSM
    ==========
        +--------------------------+--------------------+
        |            FSM           |        STATE       |
        +--------------------------+--------------------+
        | RRC TOP FSM              |CAMPED              |
        | RRC SEARCH FSM           |CAMPED_ANY          |
        | RRC ACTIVE FSM           |IDLE                |
        | PMM PLMN FSM             |ANY_CAMPED          |
        | EMM MAIN FSM             |NULL                |
        | EMM AUTH FSM             |NULL                |
        | EMM CONN FSM             |NULL                |
        | EMM TAU FSM              |NULL                |
        | EMM TEST FSM             |NULL                |
        | ESM BEARER FSM           |BEARER_NULL         |
        | SMS MT FSM               |IDLE                |
        | SMS MO FSM               |IDLE                |
        | HP MAIN FSM              |IDLE                |
        | HP USIM FSM              |READY               |
        | HP SMS MO FSM            |IDLE                |
        | HP SMS MT FSM            |IDLE                |
        | HP CAT FSM               |IDLE                |
        +--------------------------+--------------------+
    
    OK
    


  • @chielvdiepen There is a problem in the lte.attach() API. @xykon adresses this in a trial firmware build at http://beta.pycom.io/nbiot-xykon/
    Please download and install that (install from file). It may fix you problem.
    See also this thread around https://forum.pycom.io/topic/3549/important-update-regarding-lte-modem-updates/83 and


 

Hello World?

Pylife on Kickstarter - November 2018








Back Us On Kickstarter >

Pycom on Twitter