Esp32 wifi bluetooth одновременно

Esp32 wifi bluetooth одновременно

Post by nrcrast » Thu Aug 09, 2018 3:17 pm

I’m working on a project that uses both Wifi (specifically the http_client component) as well as BLE. They both seem to work great separately.

However, once Wifi establishes a connection and starts working (a small http request every second or so), the BLE feels starved. It takes a very long time to get connected, reads take in the order of seconds, and I often get disconnected.

Any idea what could cause this behavior?

Re: WIFI/BLE Simultaneously

Post by nrcrast » Mon Aug 13, 2018 1:04 pm

Sorry to bump, but either I must be doing something wrong, or there’s an issue with the stack.

Is there an example that does WIFI and BLE at the same time? Is it expected to work fine?

Re: WIFI/BLE Simultaneously

Post by chegewara » Mon Aug 13, 2018 5:37 pm

BLE + WIFI works fine but its not easy to optimize app to make it work without issues. You have to remember its shared radio and you have to give some time to wifi and ble to operate. My suggestion is to start with very simple app with 2 tasks, 1 for wifi and 1 for ble. In each task setup long delay, then make it shorter and shorter and see how it works for you.

I have one arduino app with wifi + ble, but its commercial app and cant share it.

Re: WIFI/BLE Simultaneously

Post by Deouss » Mon Aug 13, 2018 8:41 pm

I don’t understand what seems to be the problem with both being used at the same time.
First of all I came across some people complaining about esp and surprisingly discover they use Arduino only for very sophisticated apps normally written in AVR environment. I myself encountered problems with different versions of Arduino so simply stopped using it for more advanced projects. In fact to fully succeed in programming microcontrollers for commercial market you should use machine Assembler only )
For two different network peripherals is best to use different execution contexts (cores?) and separate their memory buffer spaces from conflicts.
Not to mention optimize performance for all kinds of connectivity scenarios

Re: WIFI/BLE Simultaneously

Post by ESP_Sprite » Tue Aug 14, 2018 2:55 am

The problem is that they share a radio; in other words, while the ESP32 is sending/receiving a BT packet, it cannot listen or send a WiFi packet. It’s like trying to keep up with talkshows on an old FM radio: you’re switching back and forth a lot, and you can usually keep up with both because of some redundancy in the sentences used, but if they talk too fast you’re going to loose track.

(Also, ‘fully succeed in programming microcontrollers for commercial market you should use machine Assembler only’ — can you qualify why you think this is the case? I’ve seen a gazillion of fully succeeded commercial products written in C/C++, and some use eve higher embedded languages like Python and Lua.)

Читайте также:  Wi fi мост от ноутбука

Re: WIFI/BLE Simultaneously

Post by Deouss » Tue Aug 14, 2018 4:06 am

ESP_Sprite wrote: The problem is that they share a radio; in other words, while the ESP32 is sending/receiving a BT packet, it cannot listen or send a WiFi packet. It’s like trying to keep up with talkshows on an old FM radio: you’re switching back and forth a lot, and you can usually keep up with both because of some redundancy in the sentences used, but if they talk too fast you’re going to loose track.

Isn’t it how routers work with multiple client packets? They never ‘loose track’ if clients ‘talk to fast’.
There should be very advanced and efficient packet queuing for both protocols and also fast filtering and data distribution as well.
I could suspect this might be done maybe on lover machine code level or very highly optimized with good design.
But considering price of the esp32 chip — having two systems separately for BT and for WF makes better sense in such case.

Re: WIFI/BLE Simultaneously

Post by ESP_Sprite » Tue Aug 14, 2018 7:25 am

Sure! The difference is that these routers all work on one channel. Let me strain the analogy a bit: It effectively is as is multiple guests on the talk show are talking at the same time, but still on one radio program: because everyone interacts on the same channel and cooperates to wait for eachother, it all works nicely. Bluetooth and WiFi, however, are two entire separate broadcasting stations that do not work together to coordinate who says what on which time, so you’re stuck switching back and forth between them, missing bits and pieces here and there if everything goes too fast. It’s not a problem that is solvable by any means of programming — in machine language or in any other language — it’s just intrinsic to the problem.

Re: WIFI/BLE Simultaneously

Post by Deouss » Tue Aug 14, 2018 12:07 pm

I found this ESP32 Bluetooth Architecture document describing in details the Bluetooth system on Esp32.
They mention limits of using only one interface by HCI. I couldn’t find more technical info on WiFi and it is interesting how both stacks are ‘switched’ to operate. In theory two cores should do the job just fine. What exactly means ‘switching between WF and BT’ ?
You mean switching context? They use same host controller or something? This could be solved with different stack architecture.

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

Re: WIFI/BLE Simultaneously

Post by Ritesh » Tue Aug 14, 2018 12:39 pm

Deouss wrote: I found this ESP32 Bluetooth Architecture document describing in details the Bluetooth system on Esp32.
They mention limits of using only one interface by HCI. I couldn’t find more technical info on WiFi and it is interesting how both stacks are ‘switched’ to operate. In theory two cores should do the job just fine. What exactly means ‘switching between WF and BT’ ?
You mean switching context? They use same host controller or something? This could be solved with different stack architecture.

Читайте также:  B570e wifi windows 10

Here 2 Cores are there into ESP32 but Radio is common for WiFi and BLE. so that might be the reason to not able to operate BLE and Bluetooth together at a time but can be used in switching mechanism.

We are also in queue to use WiFi and BLE or WiFi and Ethernet or WiFi and GSM or Ethernet and GSM like way combinations for some of our products.

Re: WIFI/BLE Simultaneously

Post by ESP_Sprite » Wed Aug 15, 2018 3:06 am

Deouss wrote: What exactly means ‘switching between WF and BT’ ?
You mean switching context? They use same host controller or something? This could be solved with different stack architecture.

Again, this is not a software issue. The ESP32 only has one radio and only one antenna. This radio and antenna, if viewed in a somewhat simplified fashion, can be used for one of six things: send a WiFi packet, send a BT packet, listen for a WiFi packet, listen for a BT packet, receive a WiFi packet, receive a BT packet. I think we actually do some magic that allows us to listen for BT and WiFi packets at the same time in some circumstances, but in general, we’re limited to doing only one of these things. To get around this, we would need a separate radio and antenna, something which is not in the current ESP32. No software hacks can change this, because it’s a hardware limitation, not a software one.

Источник

Arduino.ru

Возможна ли одновременная работа WiFi и Bluetooch на ESP32

Приветствую всех. Может кто то уже делал такой симбиоз? Задача стоит принять от BLE 16 байт и обработав отправить по Wifi в сеть. Или железяка не сможет этого? Так сказать котлеты отдельно, мухи отдельно.

andycat аватар

Возможна, а форуме уже было, надо выбрать в arduino ide нужную плату, но места для скетча остаётся мало в любом случае. Воспользуйтесь поиском в интернете.

Только надо учитывать, что антенна для обоих интерфейсов используется одна и та же, поэтому возможны всякие неожиданные таймауты.

Да удалось спасибо вам за наводку. Вот сейчас и возник вопрос по одновременной работе. Andicat прав памяти не хватает. Перебор на 8%. Andicat, а не подскажете какую надо плату выбрать в IDE чтобы скомпилить и всё влезло?

Отключи OTA и файловую систему.

Приветствую всех форумчан. Респект нашим китайским друзьям. Всё получилось, даже сам не ожидал. Не пришлось ни чего отключать. В одном скетче одновременно работает

1. WiFi сеть, UDP протокол 2.BLE сканер (читает показания весов) 3.Обновление по воздуху(OTA) 4.Настройка устройства через WEB морду 5.Вывод показаний на дисплей (i2c) 6.RFID считыватель PN532 NFC 7.Купюрник и монетник (по прерыванию работают). 8. Подключение к роутеру через собственную точку доступа. И весь этот микс тянет ESP32, при этом без каких либо видимых тормозов. Нашел библиотеки, которые заняли очень мало места. Памяти остается ещё достаточно, чтобы ещё что то впихнуть. Так что благодарю всех, кто давал советы, и писал качественные и без глючные библы. Ну и конечно производителей железа.

Читайте также:  Неправильно введен пароль вай фай

Источник

Making ESP32 WiFi/Bluetooth work together

I’m creating a App that involves Bluetooth and WiFi. I firstly connect the Phone to the Bluetooth and pass the WiFi ssid and password through it. Then after receiving the ssid and the password I attempt to connect it to the WiFi. I manage to store the ssid and password into a char array.

After sending the data from Bluetooth, and the ESP32 making the connection with the WiFi, the Bluetooth gets disconnected. I can’t connect the Bluetooth again because WiFi is connected, since I control certain statements from the code via Bluetooth.read(), I will need to allow the connection to coexist between WiFi and Bluetooth.

The project consist on SPIFFS (Flash memory saving). The WiFi ssid and password are passed from Bluetooth firstly, then, I make the connection from the Bluetooth data received into a char array, so I can connect it to the internet later on.
I thought firstly on adding a callback that alerts when the device is attempting to connect, but couldn’t find in the documentation any code that was able to do so. I have a callback function that tells me when the device connects and disconnects.

I searched up and found something about Menuconfig but I couldn’t find where it was located.
This is what I was reading from: https://www.espressif.com/sites/default/files/documentation/ESP32_FAQs__EN.pdf

5.3.2. How do ESP32 Bluetooth and Wi-Fi coexist? In the menuconfig menu, there is a special option called “Software controls WiFi/ Bluetooth coexistence”, which is used to control the ESP32's Bluetooth and Wi-Fi coexistence using software, thus balancing the coexistence requirement for controlling the RF module by both the Wi-Fi and Bluetooth modules. Please note that if Option “Software controls WiFi/Bluetooth coexistence” is enabled, the BLE scan interval shall not exceed 0x100 slots (about 160 ms). 

I couldn’t find where menuconfig was located.
I’m using the «`BluetoothSerial.h« library
This is a piece of the code:

// ------------------------------ Inicialização do loop ------------------------------ // void loop() < // Preparando String para enviar ao usuario line_one_length = line_one.length(); line_two_length = line_two.length(); line_three_length = line_three.length(); char receive_line_one[line_one_length], receive_line_two[line_two_length], receive_line_three[line_three_length]; char receive_wifi_ssid[line_one_length], receive_wifi_pass[line_two_length]; String deletar; file = SPIFFS.open("/wifi.txt"); // ------------------------------ Ve se o usuario digitou a palavra deletar ------------------------------ // if (SerialBT.available())< while (SerialBT.available()) < insert_chars = SerialBT.read(); deletar = String(deletar + insert_chars); >deletar.trim(); > // ------------------------------ Conexão ao WiFi ------------------------------ // if (line_one != "" and wifi_state == 0 and receive_wifi_ssid != "") < line_one.toCharArray(receive_wifi_ssid, line_one_length); line_two.toCharArray(receive_wifi_pass, line_two_length); delay(100); WiFi.begin(receive_wifi_ssid, receive_wifi_pass); Serial.println("Conectando ao WiFi. "); while (WiFi.status() != WL_CONNECTED) < Serial.print("."); delay(1000); >Serial.println("\nConectado ao WiFi"); wifi_state = 1; > Serial.print("Estado: "); Serial.println(connection_state); // ------------------------------ Vê se a conteudo dentro do FILE ------------------------------ // if (file.size() > 0) < if (deletar == "deletar")< delete_file_info(); wifi_ssid = ""; wifi_password = ""; database_info = ""; line_one = ""; line_two = ""; line_three = ""; wifi_state = 0; Serial.println("Arquivo deletado com sucesso"); return; >read_file_info(); all_lines(); >else< if (wifi_ssid == "" and connection_state == 0 and line_one == "")< Serial.print("File size: "); Serial.print(file.size()); Serial.println(", O valor dentro da string é nulo, nada será adicionado ao arquivo"); delay(1000); >else if (connection_state == 1 and line_one == "") < // Chamando a função para armazenar os dados do usuario dentro do FILE bluetooth_while_loop(); >> file.close(); delay(3000); 

Источник

Оцените статью
Adblock
detector