Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    GPy Skips LTE Code on First Run

    Scheduled Pinned Locked Moved GPy
    2 Posts 2 Posters 24 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B Offline
      B Taylor
      last edited by

      I recently got my hands on a GPy for LTE development, and am having a difficult time with the LTE configuration. I am able to get the board attached and connected to the network, but every time I plug in the device and run the code for the first time, it skips all of the AT commands that are sent, and will only execute these after the initial run. This is making me unsure about the reliability of the network connection for the application I plan to use it for.

      Right now I am using some of the example code provided by the LTE example on the Pycom website, as I am unable to find many other projects that use this configuration. The final goal is to read the incoming messages on the sim card, and execute specific responses and functions based on keywords sent to the card.

      Thanks in advance.

      from network import LTE
      import time
      import socket
      
      lte = LTE()
      
      def getLTE():
          lte.attach(band=4, apn="MY_APN")
          print("attaching...\n",end='')
          while not lte.isattached():
              time.sleep(1)
              print("not attached.")         # get the System FSM
          print("attached!")
      
          lte.connect()
          print("connecting [##",end='')
          while not lte.isconnected():
              time.sleep(0.5)
              print('#',end='')
              #print(lte.send_at_cmd('AT!="showphy"'))
              print("not connected.")
          print("] connected!")
      
          #print(socket.getaddrinfo('pybytes.pycom.io', 80))
      
      
      try:
          getLTE()
          print(lte.send_at_cmd('AT+CMEE=1')) # Enable debugging ERROR codes
          print(lte.send_at_cmd('AT+CMGF=1')) # Set modem into TEXT mode (PDU Mode by default)
          lte.send_at_cmd('AT+CPMS="ME","SM","SR"') # Set parameters for send/store sent/store new
          
          #print(lte.send_at_cmd('AT+CMGL="ALL"')) # List messages that are available
          text = lte.send_at_cmd('AT+CMGR=4') # Read recent message
          text_split = text.split()        # Split AT read into list
      
          if text_split[3] == "Voltage":   # Check if the message is asking for voltage
              print("Voltage received \n") # Print received message for verification
              # Function will then be executed 
      
      
      except Exception:
          pass # do nothing on error
      
      
      lte.deinit()
      
      E 1 Reply Last reply Reply Quote 0
      • E Offline
        Elizar @B Taylor
        last edited by

        @B-Taylor There are always problems with AT commands once you are connected() to LTE.
        To resolve this, execute the AT commands before connecting and seek "data mode" in the modem documentation on how to exit and re-enter data mode.

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • 1 / 1
        • First post
          Last post

        Pycom on Twitter

        Pycom