LTE M1 Melbourne - May help others

  • #---------- Comments Below ---------------
    #Where I'm @ - 20 March 2018, micksta.
    #p.s. I wish I knew what I was doing - wife and kids would agree
    #Telstra LTE M1 - Melbourne, March 2018
    #Hardware - Gpy + LTE E antenna + Expansion bd
    #note: thks forum guy's, put this together from various threads, you guy's :)
    #Delay's thrown in, else modem becomes flaky/hangs then hard boot/reset's required

    #import os
    #os.uname() -- Had all sorts of hanging and other stuff going on with later f/w the below seems semi ok
    #(sysname='GPy', nodename='GPy', release='1.17.0.b1', version='v1.8.6-849-d0dc708 on 2018-02-27', machine='GPy with #ESP32')

    #Atom & pymakr installed for dev.
    #All jumpers on breakout board removed except for Rx/Tx using usb/serial lead for debugging
    #Had to clean out & to nothing
    #E Antenna orientation and placement seem important (have the E antenna in E orientation and highish location)
    #Broughts Aldi nano sim $5.00 (aka telstra) network, registerd sim & chk'd in phone first
    #Aldi APN = / got this when sim was in phone
    #()"", 23) runs well - Txt Animation, slow due to ~300 kbs LTE M1 - but otherwise ok for testing #connection
    #If locks up - have to do hard reset (i.e pull usb lead out/in), port was/is copping a flogging
    #---------- Comments Above ---------------

    from network import LTE
    import time
    import usocket
    import gc


    lte = LTE() # instantiate LTE object

    print ('01') # used for debugging

    lte.send_at_cmd('AT+CGDCONT=1,"IP",""') # Aldi (APN = "", nano sim - aka telstra network
    print ('02') # used for debugging

    lte.send_at_cmd('AT!="addscanfreq band=28 dl-earfcn=9410"') # lte frequency band - from forum
    print ('03') # used for debugging

    lte.send_at_cmd('AT+CFUN=1') # Set the full functionality mode with a complete software reset
    print ('04') # used for debugging

    lte.attach() # attach the cellular modem to a base station
    while not lte.isattached():
    ----time.sleep(4.0)# should be indented!
    print ('attached') # used for debugging

    lte.connect() # start a data session and obtain an IP address
    while not lte.isconnected():
    ----time.sleep(4.0) # should be indented!
    print ('connected') # used for debugging

    print("ok good to go") # used for debugging

    #---------- Star Wars Animation -----test if connected---------------
    addr_info = usocket.getaddrinfo("", 23)
    addr = addr_info[0][-1]

    s = usocket.socket()

    while xx < 10: # else entire animation will play out
    ----data = s.recv(500) # should be indented!
    ----print(str(data, 'utf8'), end='') # should be indented!
    ----xx+=1# should be indented!

    print('----> Finished/Out')


    Re: Gpy on Telstra Australia - Melbourne LTE-M1

  • @micksta

    15 Oct 2018 - Ran this code on Telstra SIM (Adelaide) using AT+CGDCONT=1,"IP","telstra.internet

  • @nathanh
    RRC::addscanfreq and addscanfreq are the same, the RRC:: just makes it explicit this is a command that is part the RRC module (there are some ambiguous command which need the explicit declaration)

    But true none of these commands is documented by Sequans, we had to find out ourselves. You can at least get some help by calling AT!="help command_you_want"

  • @micksta
    Just a quick observation I noted, the AT command to set the scan band is slightly different in your code than it is in the firmware (ignoring the EARFCN).

    From the firmware the AT command is/would be:

    AT!="RRC::addscanfreq band=28 dl-earfcn=9410"

    And yours being:

    AT!="addscanfreq band=28 dl-earfcn=9410"

    I guess if you have it working that RRC:: is not required but just something I noticed. Would be nice if Sequans would release more of their commands so we knew what they did and help us work these issues out.

  • #Where I'm @ - 17 April 2018, micksta.
    #p.s. I wish I knew what I was doing - the boss would also
    #code below is mix from forum, again thks lads, nice for debugging
    #upgraded fw (cheers) in Gpy & Modem (M1 only) to latest , had issue not being able to upload entire ~5.4mb M1 file to sd #card, got there with a few minor scratch's!
    #during day have found modem can take ~5 sec --> min's. to attach, @ night connect time seems improved!!

    import os
    import time
    import gc
    import usocket
    #import socket - I've had issues with this in past, swapped to usocket!
    import ssl
    from network import LTE
    #(sysname='GPy', nodename='GPy', release='1.17.3.b1', version='v1.8.6-849-83e2f7f on 2018-03-19', machine='GPy with ESP32')
    lte = LTE()
    def send_at_cmd_pretty(cmd):
        response = lte.send_at_cmd(cmd).split('\r\n')
        for line in response:
    send_at_cmd_pretty('AT!="addscanfreq band=28 dl-earfcn=9410"') # lte frequency band - from forum
    send_at_cmd_pretty('AT+CGDCONT=1,"IP",""') # Aldi sim / "" Aldi APN (aka Telstra network)
    send_at_cmd_pretty('AT+CEREG=2') # pg 150 Monarch_4G_EZ...pdf, sets --> enable network registration and location information unsolicited result code
    send_at_cmd_pretty('AT+CFUN=1') # enable modem & set to full functionality mode
    while not lte.isattached():
        send_at_cmd_pretty('AT+CEREG?') #--> pg 150 Monarch_4G_EZ...pdf -- returns info see below,
        # +CREG: <n>,<stat>[,[<lac>],[<ci>],[<AcT>][,<cause_type>,<reject_cause>]]
        # i.e. +CEREG: 2,1,"3052","08195A0B",7
        # <n> is the initial setting of CEREG config i.e 2 --> ('AT+CEREG=2' / enable network registration and location information..)
        # ,<stat> -- Network registration status i.e. 1 (registered, home network)
        #      0 not registered, MT is not currently searching an operator to register to
        #      1 registered, home network
        #      2 not registered, but MT is currently searching a new operator to register to
        #      3 registration denied
        #      4 unknown (e.g. out of GERAN/UTRAN/E-UTRAN coverage)
        #      5.....10
        # ,<tac> String type; two byte tracking area code in hexadecimal format (e.g. "3052" equals 12370 in decimal).
        # ,<ci> String type; four byte E-UTRAN cell ID in hexadecimal format (e.g. "08195A0B" cell iD in Hex )
        # ,<AcT> Integer. The parameter sets/shows the access technology of the serving cell. (e.g 7 = E-UTRAN)
    lte.connect()       # start a data session and obtain an IP address
    while not lte.isconnected():
    print ('connected - lets get some data') # used for debugging
        #--- Star Wars Animation --------------------------------------------
        addr_info = usocket.getaddrinfo("", 23)
        addr = addr_info[0][-1]
        # If you type addr_info and addr at the prompt you will see exactly
        # what information they hold.
        s = usocket.socket()
        while xx < 30: # else entire animation will play out
            data = s.recv(500)
            print(str(data, 'utf8'), end='')
        #s = socket.socket()
        #s = ssl.wrap_socket(s)
        #s.connect(socket.getaddrinfo('', 443)[0][-1])
        #s.send(b"GET / HTTP/1.0\r\n\r\n")
        print('data/socket error')
    print('disconnect & detach modem')
    print('clean up')
    lte = None

  • @micksta This was quite helpful indeed. I have added a couple of lines after the LTE instantiation that disconnect/dettach it otherwise it seems to hang sometimes if something goes wrong with the code and I reboot it.

    Also, I am having some trouble running the program sometimes or reprogramming the device. I think this is related to the network -> LTE class. I spend up to several minutes getting the REPL back, once I do I erase the flash quickly to prevent further glitches...

  • @micksta That's very encouraging. Thanks for that Mick.

  • @Paddy

    re: Aldi sim (works, sure) / cat-m1 or nb-iot

    read these posts, others as well

    --> Home / Getting Started / FiPy / Telstra LTE Cat-M Working on FiPy .... Just..
    --> Home / Getting Started / FiPy / Successful network connections?


    Network Test

  • G'day Mick,

    So does this work ? Are you getting connectivity using the ALDI sim on the Telstra network. Is this cat-m1 or nb-iot.




Hello World?

Pylife on Kickstarter - November 2018

Back Us On Kickstarter >

Pycom on Twitter