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

    BLE RSSI level

    Scheduled Pinned Locked Moved WiPy 2&3
    7 Posts 3 Posters 3.2k Views 3 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
      the_ned
      last edited by

      Hello everybody,

      I am trying to use the RSSI of the BLE scanning on Wipy to send some message when some threshold is reached. But unfortunately, the reported values during the scan seems to be randomly generated. It goes from -15 to -60 without any update of the emitter location. And there is no significant change in values when the emitter us far away and still detectable.
      I thought it was related to the onboard antenna, but with the external antenna plugged, behaviour is still unchanged.

      Did you already noticed that ? Is there a way to activate the use of external antenna?
      Did i make something wrong or is there a problem with my WiPy chipset?

      Thanks

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jmarcelino @the_ned
        last edited by jmarcelino

        @the_ned
        Yes, you need to activate the external antenna even for Bluetooth.

        It's not very intuitive - or documented! - as you have to do it through the WiFi module (Bluetooth shares the same radio hardware)

        Something like this should work

        from network import WLAN
        wlan = WLAN(mode=WLAN.STA, antenna=WLAN.EXT_ANT)
        

        replace WLAN.STA with WLAN.AP if you're not connecting to your own WiFi and want the WiPy to create it's own WiFi network (the default). You can also use the wlan.antenna(WLAN.EXT_ANT) function.

        then use your Bluetooth code as usual. I've not checked the accuracy of the RSSI values yet though.

        sorenS 1 Reply Last reply Reply Quote 0
        • T Offline
          the_ned
          last edited by

          Hi,

          I have made the test. Actually it did not changed anything in the RSSI level accuracy.
          I will try using a LoPy instead WiPy and give you some feedback.

          (mac=b'\xc3\xf3\x12\x00\x02\xd1', addr_type=1, adv_type=1, rssi=-29, data=b'\x02\x01\x06\x1a\xffL\x00\x02\x15\xd9F\xb9\xf0\r\xb3E\t\xb1\xbb\xa3tgX\x98\x01\x00\x00\x01\xcb\x00') (mac=b'\xc3\xf3\x12\x00\x02\xd1', addr_type=1, adv_type=1, rssi=-53, data=b'\x02\x01\x06\x1a\xffL\x00\x02\x15\xd9F\xb9\xf0\r\xb3E\t\xb1\xbb\xa3tgX\x98\x01\x00\x00\x01\xcb\x00')
          (mac=b'\xc3\xf3\x12\x00\x02\xd1', addr_type=1, adv_type=1, rssi=-29, data=b'\x02\x01\x06\x1a\xffL\x00\x02\x15\xd9F\xb9\xf0\r\xb3E\t\xb1\xbb\xa3tgX\x98\x01\x00\x00\x01\xcb\x00') (mac=b'\xc3\xf3\x12\x00\x02\xd1', addr_type=1, adv_type=1, rssi=-41, data=b'\x02\x01\x06\x1a\xffL\x00\x02\x15\xd9F\xb9\xf0\r\xb3E\t\xb1\xbb\xa3tgX\x98\x01\x01\x00\x01\xcb\x00')
          (mac=b'\xc3\xf3\x12\x00\x02\xd1', addr_type=1, adv_type=1, rssi=-59, data=b'\x02\x01\x06\x1a\xffL\x00\x02\x15\xd9F\xb9\xf0\r\xb3E\t\xb1\xbb\xa3t`gX\x98\x01\x01\x00\x01\xcb\x00')
          (mac=b'\xc3\xf3\x12\x00\x02\xd1', addr_type=1, adv_type=1, rssi=-25,

          T J 2 Replies Last reply Reply Quote 0
          • T Offline
            the_ned @the_ned
            last edited by

            OK,
            I tried using the Lopy with or without external antenna and the RSSI level provided are too inconsistent and not reliable.
            It is a showstopper for what I have planned to use the chipset. I hope it could be solved quickly. Usually BLE chipset are quite good at Signal Strength measurement.

            It could anyway be interesting to see if someone have the same poor results when executing the code . Here after is my short test code.

            from network import Bluetooth
            from machine import Timer
            from network import WLAN
            
            chrono = Timer.Chrono()
            chrono.start();
            
            bluetooth = Bluetooth()
            print("start")
            wlan = WLAN(mode=WLAN.STA, antenna=WLAN.EXT_ANT)
            while True:
                bluetooth.start_scan(-1)    # start scanning with no timeout
                while bluetooth.isscanning():
                    adv = bluetooth.get_adv()
                    if adv:
                       print(adv)
            
            1 Reply Last reply Reply Quote 0
            • J Offline
              jmarcelino @the_ned
              last edited by jmarcelino

              @the_ned
              I found a post on the ESP32 forum about the same problem so it seems it's happening at a lower level. Maybe some calibration isn't correct or maybe something due to the recent WiFi coexistence.

              http://www.esp32.com/viewtopic.php?f=2&t=818

              When it's fixed by Espressif in the ESP-IDF it should reflect very quickly on MicroPython, the values come directly from there.

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

                @jmarcelino

                You are certainly right. That is the same problem. Actually the returned values are strange, with the same variation pattern. It is like the decoding was wrong, maybe some inversion in some bits or a Little or big endian inversion.

                Thanks for your support. I hope it will be corrected soon.

                1 Reply Last reply Reply Quote 0
                • sorenS Offline
                  soren @jmarcelino
                  last edited by

                  @jmarcelino will you need to activate the external antenna even if you don't use an antenna for bluetooth ? just wondering, because i get horribly unstable rssi values...

                  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