WIFI/BLE Simultaneously

Pcborges
Posts: 37
Joined: Thu Aug 09, 2018 9:56 pm

Re: WIFI/BLE Simultaneously

Postby Pcborges » Fri Oct 04, 2019 11:50 pm

Hi, it is said above that using BT and WiFi at the same time as long as they are not used simultaneously may work.

I cannot make it work even when only one is used at any one time.

I have a ESP32-CAM that sends emails with photos but needs WiFi connection.
Wifi credentials are stored on SD card.
Asking users to remove the SD card to configure WiFi credentials is quite a pain, most cannot do it.

So I decided that I could use Bluetooth to setup a config.txt file with the necessary credentials and the problem would be solved.

The problem is that I cannot make ESP32 WiFi and Bluetooth (serial) work activated (even not transmuting) at the same time.

I would like to keep Bluetooth on for about 2 minutes when the the system is powered up then switch off Bluetooth and let WiFi take over.

I can indeed switch off Bluetooth using the command btStop(); but, although Bluetooth disconnects and WiFi can connect back to the router connection with the mail server always fail.

Removiing the following line from Setup() solves the problem.
// inti Bluetooth
SerialBT.begin("myBT"); //Bluetooth device name

Assistance welcome.
Thanks
Paulo

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: WIFI/BLE Simultaneously

Postby Ritesh » Sun Oct 27, 2019 11:22 am

tipo1000 wrote:
Tue Mar 12, 2019 6:10 am
ESP32 needs to collect heart rate data at the same time it is sending previously collected data over wifi.

Heart rate sensor sends heart rate data to ESP32 once every second.
Forming wifi connection to router and sending previously collected data to database takes about 4 seconds.

Would this work?

Thanks,
Tipo
Hello Tipo,

Sorry for late reply. Yes. It is possible as per your requirements.

Let me know if you have any concern or query for same.
Regards,
Ritesh Prajapati

jimhelios
Posts: 39
Joined: Sun Nov 10, 2019 2:35 pm

Re: WIFI/BLE Simultaneously

Postby jimhelios » Mon Feb 10, 2020 7:17 am

Along the same lines, I'm planning an ESP32 project that will stream data through wifi to a web client using web sockets, but also I want to monitor BLE to detect that a remote button has been pressed. If I understand the problem correctly, the issue is that the ESP32 uses the same radio and antenna for both wifi and BLE. So do I have to switch the radio back and forth or will the ESP32 handle that? It's important that I don't miss a button press. I would appreciate comments, thank you.

Dmytro
Posts: 1
Joined: Fri Jul 31, 2020 1:57 pm

Re: WIFI/BLE Simultaneously

Postby Dmytro » Fri Jul 31, 2020 2:01 pm

jimhelios wrote:
Mon Feb 10, 2020 7:17 am
Along the same lines, I'm planning an ESP32 project that will stream data through wifi to a web client using web sockets, but also I want to monitor BLE to detect that a remote button has been pressed. If I understand the problem correctly, the issue is that the ESP32 uses the same radio and antenna for both wifi and BLE. So do I have to switch the radio back and forth or will the ESP32 handle that? It's important that I don't miss a button press. I would appreciate comments, thank you.
Did you cope with your task, because I also have such a task and do not know where to even look for answers? :(

dherrington
Posts: 1
Joined: Sun Aug 02, 2020 7:54 pm

Re: WIFI/BLE Simultaneously

Postby dherrington » Sun Aug 02, 2020 7:59 pm

I am stuck on this WIFI/BLE Coexistence challenge. There are good comments and ideas here, but I can't find any working coexistence examples, so I can try and implement some of the suggestions made here. Can anyone post a link to a working WIFI/BLE Coexistence working example? Thanks in advance.

wayne_peacock
Posts: 2
Joined: Tue Sep 22, 2020 5:50 am

Re: WIFI/BLE Simultaneously

Postby wayne_peacock » Tue Sep 22, 2020 7:37 am

dherrington wrote:
Sun Aug 02, 2020 7:59 pm
I am stuck on this WIFI/BLE Coexistence challenge. There are good comments and ideas here, but I can't find any working coexistence examples, so I can try and implement some of the suggestions made here. Can anyone post a link to a working WIFI/BLE Coexistence working example? Thanks in advance.
I notice Espressif has an example in the esp-idf. Found at esp-idf/examples/bluetooth/esp_ble_mesh/ble_mesh_wifi_coexist/

Has anyone successfully got this example working? I can get it to compile and load into my ESP-WROVER-Kit V1.4. From the terminal I can connect to my wi-fi successfully and get a IP and that's about all I can get working.

I can run 'iperf -s -i 3 -t 1000' on the ESP32, but every time I try to connect to it from a PC (tried Linux/Win10 and Yes, iperf 2.X) I get connection refused. I can run iperf between two different PC's without issues, so it's not firewall networking issues. The problem seems to be the ESP32 side. I have tried different settings, making the ESP32 the server and client without any luck.

I can run the example /wifi/iperf without any issues, proving the issue is with the ble_mesh_wifi_coexist example.

Also on the BLE_Mesh side (ble_mesh_wifi_coexist example), I can see the ESP32 broadcasting a beacon "ESP-BLE_MESH" which I can connect to via Nordic's nRF connect, but Espressif's "ESP-Mesh" app on Android will never find it. Why? My Android device only supports BLE 4, however as nRF connect on the same Android device works, I don't think this is the issue.

Many Thanks
Wayne Peacock

wayne_peacock
Posts: 2
Joined: Tue Sep 22, 2020 5:50 am

Re: WIFI/BLE Simultaneously

Postby wayne_peacock » Thu Sep 24, 2020 5:08 am

wayne_peacock wrote:
Tue Sep 22, 2020 7:37 am
I can run 'iperf -s -i 3 -t 1000' on the ESP32, but every time I try to connect to it from a PC (tried Linux/Win10 and Yes, iperf 2.X) I get connection refused. I can run iperf between two different PC's without issues, so it's not firewall networking issues. The problem seems to be the ESP32 side. I have tried different settings, making the ESP32 the server and client without any luck.
IDF V4.1 (stable)

There is a few bugs in cmd_wifi.c that prevents this from working. After a little bit of stuffing around I now have it working. I will put in a bug fix request.

Basically iperf is always given an uninitialised server address. Also the server address for iperf is always fixed with your ESP32 ip address from the looks of it, so only run iperf server on it, don't try to run the client.

cmd_wifi.c line 348: cfg.sip = wifi_get_local_ip(); <SIP will always be your local address!

The bigger program is wifi_get_local_ip() will always pass a uninitialised value.
initialise_wi-fi(void)

Line 132: esp_netif_t *sta_netif = esp_netif_create_default_wifi_sta(); <-- This can't be private as wifi_get_local_ip() needs it.

Still struggling to get the BLE_Mesh to provision, but that's a separate section.

Regards
Wayne Peacock

User avatar
redradist
Posts: 30
Joined: Sat Apr 11, 2020 8:33 am

Re: WIFI/BLE Simultaneously

Postby redradist » Thu Oct 08, 2020 6:53 am

Is there any update to this post ?

Seems like this is possible in current ESP-IDF SDK according the documentation https://www.espressif.com/sites/default ... Qs__EN.pdf section 5.3.2.How do ESP32 Bluetooth and Wi-Fi coexist?

I have enabled both options Software controls BLE/Wi-Fi coexisting and Coexisting Bluetooth Side Option, but nothing helps ...

According documentation I have to set intervals scan 160 ms, but I cannot find option in menuconfig how to do this ...

I use NimBle framework in ESP32
I tried to use `ESP_ERROR_CHECK( esp_wifi_set_ps(WIFI_PS_MIN_MODEM) ); //must call this` power mode for wifi, but this did not help

Any help would be appreciated ??

User avatar
redradist
Posts: 30
Joined: Sat Apr 11, 2020 8:33 am

Re: WIFI/BLE Simultaneously

Postby redradist » Thu Oct 08, 2020 9:30 am

arunbm123 wrote:
Wed Mar 20, 2019 5:45 am
Hi

after many days struggling I could integrate Ble and Wifi.
I had problem of memory leakage which i fixed.
Right now I am able to scan 50ibeacons and send to MQTT every vtaskDelay(20)
Could you explain what you have fixed for this solution to work ?
What dirty magic did you use ? :)

User avatar
redradist
Posts: 30
Joined: Sat Apr 11, 2020 8:33 am

Re: WIFI/BLE Simultaneously

Postby redradist » Sat Oct 10, 2020 11:34 am

I also have got the error:
```
LE connection complete. handle=0 role=1 paddrtype=1 addr=6d.77.b5.d5.54.40 local_rpa=0.0.0.0.0.0 peer_rpa=0.0.0.0.0.0 itvl=39 latency=0 spvn_tmo=500 mca=1
0x40 0x54 0xd5 0xb5 0x77 0x6d
connection established; status=0 handle=0 our_ota_addr_type=0 our_ota_addr=30:ae:a4:dd:9b:ee our_id_addr_type=0 our_id_addr=30:ae:a4:dd:9b:ee peer_ota_addr_type=1 peer_ota_addr=6d:77:b5:d5:54:40 peer_id_addr_type=1 peer_id_addr=6d:77:b5:d5:54:40 conn_itvl=39 conn_latency=0 supervision_timeout=500 encrypted=0 authenticated=0 bonded=0

ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0007 len=0
0x07 0x20 0x00
Command complete: cmd_pkts=5 ogf=0x8 ocf=0x7 status=0
ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0008 len=32
0x08 0x20 0x20 0x17 0x02 0x01 0x06 0x03 0x03 0x11 0x18 0x0c 0x09 0x73 0x74 0x75 0x66 0x66 0x2d 0x65 0x73 0x70 0x33 0x32 0x02 0x0a 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Command complete: cmd_pkts=5 ogf=0x8 ocf=0x8 status=0
GAP procedure initiated: advertise; disc_mode=2 adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0006 len=15
0x06 0x20 0x0f 0x30 0x00 0x60 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x07 0x00
Command complete: cmd_pkts=5 ogf=0x8 ocf=0x6 status=0
ble_hs_hci_cmd_send: ogf=0x08 ocf=0x000a len=1
0x0a 0x20 0x01 0x01
Command complete: cmd_pkts=5 ogf=0x8 ocf=0xa status=0
ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0016 len=2
0x16 0x20 0x02 0x00 0x00
Command Status: status=0 cmd_pkts=5 ocf=0x16 ogf=0x8
LE Remote Used Features. handle=0 feat=ff 00 00 00 00 00 00 00
LE Remote Connection Parameter Request. handle=0 min_itvl=6 max_itvl=6 latency=0 timeout=500
ble_hs_hci_cmd_send: ogf=0x08 ocf=0x0020 len=14
0x20 0x20 0x0e 0x00 0x00 0x06 0x00 0x06 0x00 0x00 0x00 0xf4 0x01 0x00 0x00 0x00 0x00
Command complete: cmd_pkts=5 ogf=0x8 ocf=0x20 status=0
ble_hs_hci_evt_acl_process(): conn_handle=0 pb=2 len=11 data=0x07 0x00 0x04 0x00 0x10 0x01 0x00 0xff 0xff 0x00 0x28
rxed att command: read group type req; conn=0 start_handle=0x0001 end_handle=0xffff
txed att command: read group type rsp; conn=0 length=6
host tx hci data; handle=0 length=24
ble_hs_hci_acl_tx(): 0x00 0x00 0x18 0x00 0x14 0x00 0x04 0x00 0x11 0x06 0x01 0x00 0x05 0x00 0x00 0x18 0x06 0x00 0x09 0x00 0x01 0x18 0x0a 0x00 0x0e 0x00 0x00 0x18
D (10445) CurrentSensor: count >= 1000: _voltage = 78mV


D (10449) NimBleGattChar: Connection handle: 0, Value handle: 24
GATT procedure initiated: notify; att_handle=24
txed att command: notify req; conn=0 handle=0x0018
host tx hci data; handle=0 length=15
ble_hs_hci_acl_tx(): 0x00 0x00 0x0f 0x00 0x0b 0x00 0x04 0x00 0x1b 0x18 0x00 0x4e 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Number of Completed Packets: num_handles=1
handle:0 pkts:1
ble_hs_hci_evt_acl_process(): conn_handle=0 pb=2 len=11 data=0x07 0x00 0x04 0x00 0x10 0x0f 0x00 0xff 0xff 0x00 0x28
rxed att command: read group type req; conn=0 start_handle=0x000f end_handle=0xffff
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Core 0 register dump:
PC : 0x4018fb33 PS : 0x00060530 A0 : 0x800e8b6b A1 : 0x3ffe2e80
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00000000 A5 : 0x3ffdbb90
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x800ebe80 A9 : 0x3ffe2e80
A10 : 0x3ffdbb90 A11 : 0x00000000 A12 : 0x3ffdbba8 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x00000008 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x4000c349 LEND : 0x4000c36b LCOUNT : 0xffffffff

Backtrace:0x4018fb30:0x3ffe2e80 0x400e8b68:0x3ffe2ea0 0x400ed82e:0x3ffe2ec0 0x400edc01:0x3ffe2f00 0x400ede12:0x3ffe2f30 0x400edefe:0x3ffe2f80 0x400eec33:0x3ffe2ff0 0x400e2645:0x3ffe3040 0x400e1b7e:0x3ffe3070 0x400e107d:0x3ffe30a0 0x400e108f:0x3ffe30c0 0x400ebc82:0x3ffe30e0 0x400d9712:0x3ffe3100 0x4008e741:0x3ffe3120
```

when I start Bluetooth and WiFI simultaneously for esp-idf release/v4.2, but the same error was at release/v4.1

Who is online

Users browsing this forum: DrMickeyLauer and 104 guests