[BTStack, ESP32] "Duplex" audio transmission

892 views
Skip to first unread message

Johnny

unread,
Nov 20, 2020, 3:01:40 AM11/20/20
to btstack-dev
Hi Guys,

I am new to this (both ESP32 and BTStack) so bare with me when I am talking nonsense, but I am looking for directions and help on something that might be simple.

What I am looking to achieve:
- I have a BT headset with microphone and an ESP32
- I have used the hsp_ag_demo and were able to connect the headset to the ESP32, I am able to start an audio connection (we will get to the details later on)
- Once I have the devices connected I am looking to get sound (best quality possible) sent to the headset and at the same time receive from the headset the sound captured by the microphone. Something very basic: Headset <--> ESP32 <--> send/receive audio on the ESP pins (I2C/PCM) to further work with it (e.g. pass it through a DAC/ADC to get analogic sound or pass it to another ESP32 on digital interface).

Questions:
1. Am I going in the right direction with BTStack + ESP32? If not, can you direct me to a better solution?
2. Can this be achieved (receiving sound in the headphones at the same time when sound from the microphone is trnasmitted)?
3. Is there another example I can use for what I need? Something more simple than HSP, I do not need telephone control.

Any kind of directions are welcomed.
Thank you!

Matthias Ringwald

unread,
Nov 26, 2020, 3:48:21 AM11/26/20
to btsta...@googlegroups.com
Hi Johnny

Duplex audio is only possible (assuming off-the-shelf headsets) with HSP and HFP. For this, SCO audio connections are used. On the ESP32, it's unclear if SCO packets can be sent correctly over their virtual HCI interface. See https://github.com/espressif/esp-idf/issues/1118

Anyway, if you can live with 8 khz audio data and don't need to process it on the ESP32, it should be possible to configure the ESP32 to provide the HSP audio over PCM/I2S, without the stack.
We did not test this, so cannot help here.

As HFP Wide-band speech requires the stack to decode mSBC (an audio codec like MP3), it's silly to route SCO data packets out over PCM/I2S, just to receive them again over a second PCM/I2S to be able to decode it and then finally, eg. output it over a third PCM/I2S interface. There might be progress on the SCO over HCI issue, but we didn't follow.

Alternatively, you can use BTstack on the STM F4 Discovery Board with a CC2564 where HSP and HFP are fully working, incl. support for outgoing I2S coded and the on-board PDM microphone.

Best
Matthias
> --
> You received this message because you are subscribed to the Google Groups "btstack-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/7f5c4028-195e-44e0-bc81-28b90e5836b7n%40googlegroups.com.

Johnny

unread,
Feb 5, 2021, 4:36:00 AM2/5/21
to btstack-dev
Hi Matthias,

Thanks for the additional information. I am coming back with replies after a long time as I am working on this project on my spare time.
The ST4 suggestion is not quite what I am looking for (it plays files, does buffering and so on).

I am looking for a much more simple and straightforward setup, for example: [BT headset with MIC] <-- BT Connection --> [Microcontroller/Device with BT interface and DAC/ADC] <-- wiring for analog stereo channels + MIC --> [Walkie-Talkie]. And in the end I would have (with this example) a walkie-talkie that is stationary, the BT controller is also stationary and a wireless headset to communicate over the walkie-talkie (both listen and talk) while moving away from the walkie-talkie and the BT controller in the BT range.

I have been looking for other much more simple controllers (not so complex and capable like ESP32) which have the BT interface and DAC/ADC integrated, all good, the headset connects and receives audio ... but they all have the same problem, they do not use the MIC of the headset, they use a MIC attached to the controller board (just like the ST4).

J.

Matthias Ringwald

unread,
Feb 9, 2021, 1:43:51 PM2/9/21
to btsta...@googlegroups.com
Hi Johnny

The HFP examples all use the btstack_audio.h interface. For the F4 Discovery port, the implementation uses the built-in not I2S DAC and the PDM microphone. Instead of the PDM microphone, it is possible to implement audio input from I2S as well. So, that's pretty close to your goal.

While not simpler than an ESP32, you could also use a Raspberry Pi Zero W with an USB Bluetooth dongle with some I2S "hat". There, I think you only need to configure the audio driver (it's still cheap btw...)

Best
Matthias
> To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/63a54138-9896-4b3e-b892-7699d604bd8cn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages