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

    to get the CSQ

    Scheduled Pinned Locked Moved FiPy
    12 Posts 2 Posters 405 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.
    • R Offline
      radheshyam0508
      last edited by

      Dear sir/mam,
      Could anyone please help me how can I get the CSQ of my network signal and how would I know that my board is connected the network?
      How can run the AT commands.

      Waiting for your positive reply.
      radhe

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @radheshyam0508
        last edited by

        @radheshyam0508 You could try this:

        from network import LTE
        lte=LTE()
        lte.attach()
        lte.send_at_cmd("AT+CSQ")
        

        Returns for me:
        '\r\n+CSQ: 25,99\r\n\r\nOK\r\n'
        lte.isattached()
        returns the attach status. A typical small test script would be:

        #
        from network import LTE
        import time
        import socket
        
        start = time.ticks_ms()
        lte = LTE()
        print("\nModem started, time needed (s): ", time.ticks_diff(time.ticks_ms(), start)/1000)
        
        start = time.ticks_ms()
        lte.attach(band=8, apn="iot.1nce.net")
        while not lte.isattached():
            time.sleep(0.5)
            print(".", end="")
        print("\nAttached!, time needed (s): ", time.ticks_diff(time.ticks_ms(), start)/1000)
        
        start = time.ticks_ms()
        lte.connect()       # start a data session and obtain an IP address
        while not lte.isconnected():
            time.sleep(0.5)
            print("-", end="")
        print("Connected!, time needed (s): ", time.ticks_diff(time.ticks_ms(), start)/1000)
        
        1 Reply Last reply Reply Quote 0
        • R Offline
          radheshyam0508
          last edited by

          @robert-hh said in to get the CSQ:

          lte.attach()
          lte.send_at_cmd("AT+CSQ")

          Thanks a lot Robert,
          Could you please send me the code for connecting the fipy NB-IoT module to the network.
          Because there is no tutorial or example code for NB-IoT.

          Thanks a lot for your help and support

          robert-hhR 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @radheshyam0508
            last edited by

            @radheshyam0508 Once the device is attached and connected, you can use the usual socket mechanism to communicate.

            R 1 Reply Last reply Reply Quote 0
            • R Offline
              radheshyam0508 @robert-hh
              last edited by

              @robert-hh
              sorry, but How would i know that my device is connected?

              robert-hhR 1 Reply Last reply Reply Quote 0
              • robert-hhR Offline
                robert-hh @radheshyam0508
                last edited by

                @radheshyam0508 Look at the example in the documentation:
                https://docs.pycom.io/tutorials/lte/nb-iot/
                which is similar to my little script I posted before. After connection, I tried a simple connection link to a PC I had set up as the server:

                data_client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                # 
                ip_address="84.147.45.246"
                port_number = 4567
                data_client.connect((ip_address, port_number))
                 
                while True:
                    msg = input("New message")
                    if msg == "q":
                        break
                    data_client.send(msg + "\r\n")
                 
                data_client.close()
                

                I lost somehow the code of the matching "server", but it was minimal. I may have type that on-the-fly at a Python REPL.

                1 Reply Last reply Reply Quote 0
                • R Offline
                  radheshyam0508
                  last edited by

                  @robert-hh said in to get the CSQ:

                  lte.send_at_cmd("AT+CSQ")

                  Hello robert,
                  after giving the AT command I got this error...
                  "OSError: LTE modem is in data state, cannot send AT commands"
                  Could you please help me how can I rectify it. I already disconnect and reconnect the module and try to send the AT commands but again I got the same error.

                  Thanks

                  robert-hhR 1 Reply Last reply Reply Quote 0
                  • robert-hhR Offline
                    robert-hh @radheshyam0508
                    last edited by

                    @radheshyam0508 Yould you try lte.deinit()?
                    It is funny that the modem is in the data state, if you did not attach or connect. Typically it is in the data state after connecting.

                    R 1 Reply Last reply Reply Quote 0
                    • R Offline
                      radheshyam0508 @robert-hh
                      last edited by

                      @robert-hh said in to get the CSQ:

                      lte.deinit()

                      So when does it reply to AT commands? When it is in DATA state or other state?

                      robert-hhR 1 Reply Last reply Reply Quote 0
                      • robert-hhR Offline
                        robert-hh @radheshyam0508
                        last edited by robert-hh

                        @radheshyam0508 It respond to AT commands when NOT in data state.
                        You could also try to send
                        lte.send_at_command("+++")
                        and then, after a few seconds
                        lte.send_at_command("ATH")
                        These are the historic commands to terminate a data session.

                        R 1 Reply Last reply Reply Quote 0
                        • R Offline
                          radheshyam0508 @robert-hh
                          last edited by

                          @robert-hh said in to get the CSQ:

                          lte.send_at_command("ATH")

                          Hey sorry Robert I am asking you more questions.
                          Now I want to know that can I send all the AT command using the python code. I don't want to send it manually. Is it possible that i can upload the AT command code with the connection establish code?

                          robert-hhR 1 Reply Last reply Reply Quote 0
                          • robert-hhR Offline
                            robert-hh @radheshyam0508
                            last edited by

                            @radheshyam0508 You can always write a python script which contains all the commands you want, and store that on the device.

                            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