BLE connection issue

  • I'm using a FiPy sitting on the PyTrack. I have updated all devices to their newest firmware version. I'm using the Bluetooth example from Github. I am some times (completely at random) able to connecto to a BLE device, but more often than not, the "connection refused" message pops up. Why? The few times I have managed to establish a connection I get this:

    connecting to b'\xd2\xe0\xd0\xeb*\xfd'
    Reading chars from service = 1800
    char 10752 value = b'SENSOR'
    char 10753 value = b'\x00\x00'
    char 10756 value = b'\x10\x00<\x00\x00\x00\x90\x01'
    Reading chars from service = 1801
    Reading chars from service = b'\x9e\xca\xdc$\x0e\xe5\xa9\xe0\x93\xf3\xa3\xb5\x01\x00@n'

    What does this mean? The BLE device is capable of transmitting: Temperature and humidity, brightness, x,y,z-coordinates and angular velpcity.

    I'm able to connect the BLE device using BLE scanner 4.0 for ios and through there I can easily read changes from the sensors.



  • Were you able to resolve this issue? I am having same issue with nRF BLE but it works with another Pycom BLE device.

  • @SimiamiDrew Could you also print the adv_type for the device before you attempt to connect?

  • @SimiamiDrew Can you please edit your post and add ``` alone on a line both before and after your code? That will format it properly. Or select the code and click on one of the two code icons in the toolbar.

  • @jcaron
    The code i'm using is:

    Insert Code Here
    from network import Bluetooth
    import binascii
    import time
    bt = Bluetooth()
    while True:
        adv = bt.get_adv()
        if adv:
            # try to get the complete name
            print(bt.resolve_adv_data(, Bluetooth.ADV_NAME_CMPL))
            # try to get the manufacturer data (Apple's iBeacon data is sent here)
            mfg_data = bt.resolve_adv_data(, Bluetooth.ADV_MANUFACTURER_DATA)
            if mfg_data:
                # try to get the manufacturer data (Apple's iBeacon data is sent here)
            if bt.resolve_adv_data(, Bluetooth.ADV_NAME_CMPL) == 'SENSOR':
                conn = bt.connect(adv.mac)
                print("connecting to",adv.mac )
                services =
                for service in services:
                    if type(service.uuid()) == bytes:
                        print('Reading chars from service = {}'.format(service.uuid()))
                        print('Reading chars from service = %x' % service.uuid())
                    chars = service.characteristics()
                    for char in chars:
                        if ( & Bluetooth.PROP_READ):
                            print('char {} value = {}'.format(char.uuid(),
    And the "connection refused"- message
    ![Connection refused.PNG](/assets/uploads/files/1559033864046-connection-refused.png)

  • @SimiamiDrew What exactly tells you "connection refused"? I don't think that concept actually exists in BLE, this looks more like an unrelated TCP thing.

    Can you share the actual code you use as well as the actual logs?

  • @jcaron Maybe, but before every test I make sure to not be connected to the device, so as to the FiPy is the only possible device that'll search and connect to the BLE device.

  • @SimiamiDrew Maybe the device only accepts one connection at a time and you have something else already connected?

Log in to reply

Pycom on Twitter