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

    Checking bandwidth available for FiPy possible?

    Scheduled Pinned Locked Moved FiPy
    3 Posts 1 Posters 107 Views 1 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
      railmonitor
      last edited by

      Hi.

      Would have posted in the "Cellular" topic, but that is unavailable.

      I am using a FiPy, which is used for sending sensor data to Azure IoT Hub using LTE NB-IoT. But i am finding that establishing the connection to Azure takes a long time, sometimes up to around 10 seconds.

      Due to power-saving reasons, i don't want it to stay connected all the time, but the wait for connecting to Azure is not optimal.

      I would like to investigate the bandwidth that we are operating with when using the LTE NB-IoT network. Is there a method that can do this in the network library?

      Is the network library available for reading?

      Best Regards
      RM

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

        Found the solution! Posting here anyone who would ask the same:

        print(lte.send_at_cmd('AT+CSQ'))
        print(lte.send_at_cmd('AT+CSQ=?'))
        

        This will show you the signal quality, and the number of errors!

        /RM

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

          So my bandwidth is not really the problem here. The problem is that the umqtt / simple library is slow in use. When my FiPy is already connected to LTE, and it then tries to connect to Azure IoT Hub, establishing the connection takes around 30 seconds, whereas simply publishing is fast and not a issue at all. So i am currently looking into optimizing / speeding up the connect routine if possible in the simple.py library.

          Here is the code i use to connect:

          def iot_connect(self):
                  if self.IoTConnectedFlag == False:
                      self.password = self.generate_sas_token(self.uri, self.primary_key, self.policy_name)
                      beforeConn = utime.ticks_us()
                      self.username_fmt = "{}/{}/api-version=2018-06-30"
                      self.username = self.username_fmt.format(self.hostname, self.device_id)
                      self.client = MQTTClient(client_id=self.device_id, server=self.hostname, port=8883, user=self.username, password=self.password, keepalive=4000, ssl=True)
                      self.client.connect()
                      print("IoT Connected!")
                      self.IoTConnectedFlag = True
                      afterConn = utime.ticks_us()
                      connDone = afterConn - beforeConn
                      print(connDone)
          

          the utime.ticks_us() are used to observe how long time the method takes to execute.

          • Whole method = 28.61 secs

          • Whole method minus SAS Token generation = 27.27 secs

          • self.client.connect() = 16.94 secs

          Any ideas on how to optimize this speed is very welcome! Thanks

          /RM

          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