Struggle with Pycom LTE



  • Hello, i´m having some problems with Pycom Gpy in LTE and wondering if someone can gimme tip or something (From Brazil here):

    I´m trying to Attach and Connect to LTE network using the following code:
    https://core-electronics.com.au/tutorials/pycom-gpy-getting-started.html
    (tutorial from core-electronics)

    The problem is this lines down:

    print("Configuring LTE ", end='')
    lte.send_at_cmd('AT+CGDCONT=1,"IP","telstra.internet"')
    print(".", end='')
    lte.send_at_cmd('AT!="RRC::addscanfreq band=28 dl-earfcn=9410"')
    print(".", end='')
    lte.send_at_cmd('AT+CFUN=1')
    print(" OK")

    I understand that the telstra.internet refeers to the Nano SIM Card. I used to use an moden for my Raspberry pi 3b and used to send this AT-commands:

    • ATZ
    • ATQ0 V1 E1 S0=0 &C1 $D2 +FCLASS=0
    • AT+CGDCONT=1,"IP","zap.vivo.com.br"
    • AT+CFUN =1,0

    And didn´t work.

    Vivo refeers to my Nano SIM Card, but i really dont know much about the AT-commands in a moldem.

    By the way, i have updated the firmware from my Gpy, the board to the Pymakr and the modem with internal commands in Atom.

    Has anyone has an idea to help me?



  • I changed my code to this:

    #code
    import socket
    import ssl
    import time
    from network import LTE
    import pycom

    pycom.heartbeat(False)

    lte = LTE(carrier="verizon") # instantiate the LTE object
    lte.attach(band=13) # attach the cellular modem to a base station, initially it was lte.attach()
    print( " While loop1") # print stmt to check on terminal
    time.sleep(5) # added 5 seconds wait
    pycom.rgbled(0x0000ff) # BLUE LED

    print(lte.send_at_cmd('ATZ'))
    time.sleep(0.5)
    print(lte.send_at_cmd('ATQ0'))
    time.sleep(0.5)

    print(lte.send_at_cmd('AT+CGDCONT=1,"IP","zap.vivo.com.br"'))
    time.sleep(0.5)
    print(lte.send_at_cmd('AT+CGAUTH=1,1,"vivo","vivo"'))
    time.sleep(0.5)

    lte.send_at_cmd('AT+CFUN=1')
    time.sleep(1)

    mood=lte.send_at_cmd('at+cpin?').split('\r\n')[1]; print('modem', mood)

    while not lte.isattached():
    print('Signal:%s'%lte.send_at_cmd('AT+CSQ'))
    lte.send_at_cmd('AT+CSQ')
    print('Status:%s '%lte.send_at_cmd('AT+CEER'))
    lte.send_at_cmd('AT+CEER')
    time.sleep(5) # originally 0.25 changed to 5.0
    lte.attach()
    lte.connect(cid=3) # start a data session and obtain an IP address
    print( " While loop2")
    pycom.rgbled(0x00ff00) # GREEN LED
    while not lte.isconnected():
    time.sleep(0.25)

    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()
    #endcode

    the message that i´m receiving is:

    Signal:
    +CSQ: 22,99

    OK

    Status:
    +CEER: lastEmmCause: NO_SUITABLE_CELLS_IN_TRACKING_AREA, lastEsmCause: EMM_NOT_ATTACHED

    Has any one has an idea of what that means? '-'



  • @rafaelFerreira You can send AT commands (lte.send_at_cmd("xxx")), and the commands for Username & password should be generic.



  • hey,
    Are there an AT-command to insert Username and Password relative to this Vivo? Like, I note that when i put the AT-commands to use a modem in Raspberry, i send another AT-commands to set Vivo Username and Password.

    Well... there are?



  • Note that if I understand things correctly, Vivo BR is currently deploying Cat-M1 and NB-IoT, so you may not necessarily be covered in your area yet.

    Also, you may need a specific subscription for this, it may not work with a regular LTE subscription (from what I understand at least NB-IoT will have specific billing structure).

    Apparently Vivo uses LTE bands 3, 7 and 28. Don't restrict yourself to a single band, coverage at your place may be available in only some of those bands. The FiPy does not support band 7, though.

    Also make sure you have recent firmware for both the modem and FiPy, and that the modem firmware you use matches the technology you want (Cat-M1 or NB-IoT).



  • @rafaelFerreira Having a good quality lte antenna is very important. Beware the cheap chinese antennas claiming 698-2700MHz range, most of 'em are 850-2700MHz which is important for band 28 (700MHz)



  • @kjm

    Hm, yeah thanks, that´s a good view.
    Just one last question: if i get the LTE antenna, will i get more success results or change the antenna is not that important?



  • @rafaelFerreira How can you be sure the frequency is the same? Do you know the band your Telco is running cat-m1 on? It's best NOT to limit the modem to certain bands. That was Nakovi's problem @ https://forum.pycom.io/topic/5576/gpy-lte-modem-does-not-respond/14 (see his last post)



  • @kjm
    Yep. I tryed this.

    Hm, question: Is it ok to use a LoRa antenna to this Attaching? Or it´s realy required the LTE antenna? The frequency is the same



  • @rafaelFerreira simreg=2 means the modem is trying to attach. Have you tried commenting out the addscanfreq line to see if it's preventing attachment?



  • @kjm
    Yeah, i actually do this reset in code:

    print("Resetting LTE modem ... ", end='')
    lte.send_at_cmd('AT^RESET')
    print("OK")
    time.sleep(2)

    and you´re right. I move this commands to my 'attach loop' see:

    #Code
    print("Configuring LTE ", end='')
    lte.send_at_cmd('AT+CGDCONT=1,"IP","zap.vivo.com.br"')
    print(".", end='')
    lte.send_at_cmd('AT!="RRC::addscanfreq band=28 dl-earfcn=9410"')
    print(".", end='')
    lte.send_at_cmd('AT+CFUN=1')
    print(" OK")
    time.sleep(1)

    mood=lte.send_at_cmd('at+cpin?').split('\r\n')[1]; print('modem', mood)
    
    
    # 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='')
            simreg=lte.send_at_cmd('at+creg?').split(',')[1][:1]; print('sim reg =', simreg, end=' ')
            service=lte.send_at_cmd('AT+cind?').split(': ')[1][2]; print('service =', service)
            time.sleep(1)
    

    and the return now is:
    sim reg = 2 service = 0

    I think the error is in
    lte.send_at_cmd('AT!="RRC::addscanfreq band=28 dl-earfcn=9410"')

    Do you know something to help?



  • @rafaelFerreira simreg & service simply confirm you don't have an attachment. Try the modem reset if you get an error for mood, that's where the problem is.



  • @kjm
    Well, i got something more specific here in this time....
    I applied this line in my code.

    mood=lte.send_at_cmd('at+cpin?').split('\r\n')[1]
    print('modem', mood)
    simreg=lte.send_at_cmd('at+creg?').split(',')[1][:1]
    print('sim reg =', simreg, end=' ')
    service=lte.send_at_cmd('AT+cind?').split(': ')[1][2]
    print('service =', service)
    time.sleep(1)

    and this was the answer:

    modem +CPIN: READY
    sim reg = 0 service = 0

    Sorry for my ignorance, but I really don't know much about it.
    Do you know something?



  • @rafaelFerreira between lte=network.LTE() and trying to attach it is worthwhile checking the modem's mood with at+cpin if you get an error then

    lte.send_at_cmd('AT^RESET')
    

    attachment only works if the mood is 'ready' or 'sysstart'



  • @kjm
    Yes, i´m sure that i´m using the correct SIM (it´s from Vivo)
    I receive the message 'modem ERROR' when i apply your command in my code



  • So you are using lte.send_at_cmd('AT+CGDCONT=1,"IP","zap.vivo.com.br"') with a zap sim & not getting an attachment?

    Is the sim current?

    What response do you get to mood=lte.send_at_cmd('at+cpin?').split('\r\n')[1]; print('modem', mood)


Log in to reply
 

Pycom on Twitter