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

    Read ICCID Not Working

    Scheduled Pinned Locked Moved Support & Troubleshooting
    iccid lte
    7 Posts 2 Posters 629 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.
    • T Offline
      tlanier
      last edited by

      We have just finished our design and PCB layout using the GPy. Everything was working great. I decided to upgrade the modem firmware to 41065. We're running release candidate v1.20.0.rc9. Now the lte.iccid() command is no longer working after a modem reset and init. If you attach to the cell network, the iccid() command then works. In our design we use the ICCID returned value to determine the proper APN to use in the attach command. Now we can't read the ICCID until we properly attach. Below is the sequence that doesn't work. I've also tried just querying the modem with the AT+SQNCCID? command, but that returns a null string until the modem is attached.

      Does anyone have any ideas how to read the SIM's ICCID value before attaching? This used to work.

      from network import LTE
      lte = LTE()
      lte.reset()
      LTE.reconnect_uart()    #in the past this command would fix problem, now it doesn't
      lte.init()
      lte.iccid()    # does not work!
      lte.send_at_cmd('AT+SQNCCID?')   # this returns null string for ICCID
      lte.attach(apn='10569.mcs')
      lte.iccid()    # now it works!
      
      T 1 Reply Last reply Reply Quote 0
      • T Offline
        tlanier
        last edited by

        Regrettably, I see I've posted the message to the wrong section of the forum.

        I have discovered a workaround to the problem.

        By adding a dummy call to the attach function, I can resolve my problem.

        Revised code below:

        from network import LTE
        lte = LTE()
        lte.reset()
        lte.init()
        sleep_ms(1500)    # not sure why delay is needed
        lte.attach(apn='unknown')    # this will fail since apn is invalid
        sleep_ms(1500)    # not sure why delay is needed
        iccid = lte.iccid()    # iccid now works
        # compute apn from iccid
        lte.attach(apn=computed_apn)    # attach now works
        1 Reply Last reply Reply Quote 0
        • T Offline
          tlanier
          last edited by

          Below is the revised code that now works. I'm going to repost this in a more appropriate location on forum in hopes that the problem may be seen by someone who can fix it.

          from network import LTE
          lte = LTE()
          lte.reset()
          lte.init()
          sleep_ms(1500)
          iccid = lte.iccid()    # does not work
          lte.attach(apn='unknown')    # attempt attach so iccid() will work
          sleep_ms(1500)
          iccid = lte.iccid()    # iccid() now works
          lte.detach(reset=False)
          # compute apn from iccid
          lte.attach(apn=computed_apn)    # attach  with correct apn
          
          1 Reply Last reply Reply Quote 0
          • T Offline
            tlanier @tlanier
            last edited by

            We have today discovered a better method to solve the problem where the lte.iccid() does not return the iccid after a modem reset. Rather that do the dummy lte.attach(apn='unknown'), doing the following works. Apparently the lte.init() command does not always properly enable the SIM card.

            Executing an "AT+CFUN=4" after the modem reset solves the problem!

            #####################################################################
            #                           Reset Modem
            #####################################################################
            def reset_modem():
                global lte
            
                g.modem_state = g.MS_RESET_MODEM
                log("reset modem...")
            
                if lte == None:
                    try:
                        lte = LTE()
                    except Exception as ex:
                        sys.print_exception(ex)
                        util.reset(27, "LTE exception")
            
                sleep_ms(0)
                lte.reset()
                sleep_ms(0)
                at('AT+CFUN=4')     # enable SIM card
            
            robert-hhR T 2 Replies Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @tlanier
              last edited by

              @tlanier I do not have this issue. I can run the following commands below after power on or reset:

              Pycom MicroPython 1.20.0.rc13 [43fa900-dirty] on 2019-09-07; FiPy with ESP32
              Type "help()" for more information.
              >>> from network import LTE
              >>> lte=LTE()
              >>> lte.iccid()
              '89882806660000016750'
              >>> lte.send_at_cmd('AT+SQNCCID?')
              '\r\n+SQNCCID: "89882806660000016750",""\r\n\r\nOK\r\n'
              
              T 1 Reply Last reply Reply Quote 0
              • T Offline
                tlanier @robert-hh
                last edited by

                @robert-hh On push button reset it works like you said; however, if you call the lte.reset() the lte.iccid() no longer works.

                I'm now trying to decide should we do an modem.at('AT+CFUN=4') or modem.at('AT+CFUN=1')?

                1 - full functionality, enable SIM card
                4 - disable phone both transmit and receive RF circuits, enable SIM card

                Is there a downside to setting the functionality to "1 - full" always? I really don't care about power usage, but I do care about best connectivity at all times.

                1 Reply Last reply Reply Quote 0
                • T Offline
                  tlanier @tlanier
                  last edited by

                  We have now discovered that even sending the "AT+CFUN=4" does not solve the problem. Yesterday we had a GPy stuck in a mode where it would not return the ICCID even after power on/off, modem reset command, and the AT+CFUN=4 command. The only thing that resolved the issue was to send a dummy attach command lte.attach(apn='unknown'). Then the lte.iccid() command worked from that point forward (even through power on/off and resets). We do not know what causes the GPy to get in this crazy mode; however, it seems to be related to low signal situations.

                  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