BLE scan between pycoms

  • Hi everyone,

    I’m trying to develop an application that continuously scan the BLE network and gets the RSSI level from some devices I selected.

    My testbed is composed by:

    • 5 WiPy3 + pysense board. Firmware: 1.18.2.r7
    • 1 WiPy3 + pysense board: Firmware: 1.17.5.b6
    • 1 WiPy3 + pytrack board. Firmware: 1.18.0

    All of them are running the same code (below) but the only board that gets BLE measurements of the other devices is the pytrack (pysenses don’t “see” each other). This is the first time that I use BLE so I might have a lack of understanding about how BLE works.

    bt = Bluetooth()
    bt.set_advertisement(name=client_id, service_uuid=b'1234567890123456')
    macs_bt = {‘MAC-1’, ‘MAC-2’, ‘MAC-3’, ‘MAC-4’, ‘MAC-5’, ‘MAC-6’, ‘MAC-7’} 
    rssi_bt = []
    def scan_bluetooth(delay):
        while True:
                rssi = {}
                advs = bt.get_advertisements()
                for ad in advs:
                    bssid = change_mac_format(ubinascii.hexlify(ad.mac).decode('utf-8'))
                    if bssid in macs_bt:
                        rssi[bssid] = ad.rssi
                if rssi:
                    rssi['timestamp'] = get_date()
            except Exception as ex:

    Any idea what’s going on?

    Thanks :)

  • @mdelhorno Please can you send you full code to . The code below is working for me:

    from network import Bluetooth
    import utime
    bluetooth = Bluetooth()
    bluetooth.set_advertisement(name='Module_1', service_uuid=b'1234567890123456')
    bluetooth.start_scan(-1)    # start scanning with no timeout
    while True:

Log in to reply

Pycom on Twitter