BLE and Wifi interference?



  • Hi to everyone!
    I noticeed a possible issue using, at the same time, BLE and wifi.
    Once created a bluetooth object, if services are exposed, i can't make a socket connection, and also the ftp server has communication problem.
    Instead if a bluetooth object is created without services no issue is arised.
    In the following code i try to create 3 bluetooth services and after that, i try to make a mqtt broker connection.

    wlan = WLAN()
    wlan.init(mode = WLAN.STA, antenna = WLAN.EXT_ANT, channel = 11)
    bt = Bluetooth()
    id = str(ubinascii.hexlify(machine.unique_id(), ':'), 'utf-8')
    bt.set_advertisement(name = 'X-DOM - '+id[9:17].upper())
    bt.advertise(True)
    bt.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONNECTED, handler=conn_cb)
    
    srv_reset = bt.service(uuid=0x77777777, isprimary=True,  nbr_chars=2, start=True)
    reset = srv_reset.characteristic(uuid = 0x11111111, properties = Bluetooth.PROP_WRITE, value = 0)
    password = srv_reset.characteristic(uuid = 0x22222222, properties = Bluetooth.PROP_WRITE, value = 0)
    password.callback(trigger=Bluetooth.CHAR_WRITE_EVENT,handler= func_password)
    reset.callback(trigger=Bluetooth.CHAR_WRITE_EVENT,handler= func_reset)
    
    srv_refresh = bt.service(uuid=0x88888888, isprimary=True,  nbr_chars=1, start=True)
    refresh = srv_refresh.characteristic(uuid = 0x33333333, properties = Bluetooth.PROP_WRITE, value = 0)
    refresh.callback(trigger=Bluetooth.CHAR_WRITE_EVENT,handler= func_refresh)
    
    srv_config = bt.service(uuid=0x99999999, isprimary=True,  nbr_chars=4, start=True)
    ch_nets = srv_config.characteristic(uuid=0x44444444, properties = Bluetooth.PROP_READ, value = 0)
    ch_nets.callback(trigger=Bluetooth.CHAR_READ_EVENT, handler=func_scanning)
    net_config = srv_config.characteristic(uuid=0x55555555, properties = Bluetooth.PROP_WRITE, value = 0)
    net_config.callback(trigger=Bluetooth.CHAR_WRITE_EVENT, handler=func_net_cf)
    mqtt_config = srv_config.characteristic(uuid=0x66666666, properties = Bluetooth.PROP_WRITE, value = 0)
    mqtt_config.callback(trigger=Bluetooth.CHAR_WRITE_EVENT, handler=func_mqtt_cf)
    notify_config = srv_config.characteristic(uuid=0x12345678, properties = Bluetooth.PROP_WRITE, value = 0)
    notify_config.callback(trigger=Bluetooth.CHAR_WRITE_EVENT, handler=func_notify_cf)
    
    client = MQTTClient(CLIENT_ID,server="projectxdom.co.uk",user=uid,password=pwd_mqtt)
    client.set_callback(sub_cb)
    if not client.connect(clean_session = True):
        client.subscribe('/rgbled/color')
        client.subscribe('PippoBaudo')
    

    In the client.connect() the wipy return the error code OSError: -76

    Instead the following code works fine

    wlan = WLAN()
    wlan.init(mode = WLAN.STA, antenna = WLAN.EXT_ANT, channel = 11)
    bt = Bluetooth()
    id = str(ubinascii.hexlify(machine.unique_id(), ':'), 'utf-8')
    bt.set_advertisement(name = 'X-DOM - '+id[9:17].upper())
    bt.advertise(True)
    bt.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONNECTED, handler=conn_cb)
    client = MQTTClient(CLIENT_ID,server="projectxdom.co.uk",user=uid,password=pwd_mqtt)
    client.set_callback(sub_cb)
    if not client.connect(clean_session = True):
        client.subscribe('/rgbled/color')
        client.subscribe('PippoBaudo')
    

    Is it a bug, or my mistake?
    Tnx



  • Even with an External Antenna the BLE seems to have quite some problems. Sometimes it doesnt find anyhting at all.



  • @duffo64
    Hi!
    No difference with internal or external antenna.



  • Hi @Paco88

    WiFi and BLE are on the same antenna and ESP32 controls access via coexistence (hardware or software).
    I see that you are explicitly enabling external antenna. What happens if you try with the onboard antenna ?

    Claudio



  • @Paco88 Someone like @robert-hh, @jmarcelino or @bucknall maybe know some other motivation



  • This may be a real problem...



  • @Paco88 I think that the INTERNAL ANTENNA and the EXTERNAL ANTENNA are too close and this can cause an interference.


 

Pycom on Twitter