Open spacetronics opened 1 month ago
Working on something similar, please note that INMP441 requires L/R to be connected to either ground or VDD. With nothing connected, the value is floating and output can randomly go to either the left or right channel.
Working on something similar, please note that INMP441 requires L/R to be connected to either ground or VDD. With nothing connected, the value is floating and output can randomly go to either the left or right channel.
i connected the L/R to GND. still not working
i connected the L/R to GND. still not working
Sorry, should have been more explicit. This wasn't to solve the issue, just something that could cause additional problems.
oh ok, thanks for the reminder!
Hi, @spacetronics
Since i've set my audio path to PCM, i have no idea why the logs are stating connected_msbc. set the value = 1 in handler_callback(value) and the connected_msbc logs are gone, but the disconnecting issue still persist.
This issue has been fixed, and the commit id of v5.3 is 3af62b6e4868f385e2f33a90af1f46eb604d8ac2. You can update the branch so that there is no need to change the idf code.
So i'm trying to run the hfp_hf example to stream my audio to my smartphone using bluetooth. I've already set my audio path configurations to PCM. I've set my INMP441 pins as: SD: GPIO_OUTPUT_PCM_DOUT (26) SCK: GPIO_OUTPUT_PCM_CLK_OUT (5) WS: GPIO_OUTPUT_PCM_FSYNC (25) L/R: Not connected The bluetooth connection between my ESP32 and smartphone was successful. But when i try to connect audio, the first audio state was connected, then connected_msbc, and then it disconnected.
There is no problem with the connection between ESP32 and smartphone. I think It may be a connection issue with the audio device (I have tried connecting other audio devices before, and there is no problem with the voice output.). I read the data sheet of INMP441. In addition to the connection of the signal pins and the L/R pin, the CHIPEN pin needs to be set high. (when set low, disabled; when set high, enabled). Please try it and see if there is still a problem?
the CHIPEN pin needs to be set high. (when set low, disabled; when set high, enabled). Please try it and see if there is still a problem?
I tested my microphone with this and the microphone worked. My INMP441 board only have VDD pin but i think its the same as CHIPEN pin (CMIIW) and i connect it to 3V3 pin in esp32. the issue sadly still persist.
the CHIPEN pin needs to be set high. (when set low, disabled; when set high, enabled). Please try it and see if there is still a problem?
I tested my microphone with this and it already worked. My INMP441 board only have VDD pin but i think its the same as CHIPEN pin (CMIIW) and i connect it to 3V3 pin in esp32. the issue sadly still persist.
If you use the common round 6 pin PCB board with the INMP441: that has CHIPEN connected to VDD internally.
If you use the common round 6 pin PCB board with the INMP441: that has CHIPEN connected to VDD internally.
Yep, i use that board. I just looked at the system block diagram in the datasheet and you're correct.
This issue has been fixed, and the commit id of v5.3 is https://github.com/espressif/esp-idf/commit/3af62b6e4868f385e2f33a90af1f46eb604d8ac2. You can update the branch so that there is no need to change the idf code.
i updated the branch and the connected_msbc log is fixed so thank you. @esp-qing
However, i followed this mic testing tutorial (it uses bluetooth) and it worked so idk why the esp idf one always disconnnected. do i need a specific application in my phone so that my mic can be heard from the phone? i use "Bluetooth Audio Connect Widget"
Having done a lot of research I can tell you that currently INMP441 will not work with HFP_HF in PCM mode. INMP441 uses Philips / 1 bit-shift / i2s the timing format, instead of the "normal" / left-aligned / "MSB" timing format. See here: https://github.com/espressif/esp-idf/issues/13738#issuecomment-2423758387
Until esp-idf allows you to configure the timing offset in menuconfig, the microphone will not function correctly and produce a lot of noise with a barely perceptible voice signal. See also this thread https://github.com/espressif/esp-idf/issues/13738
Now why it's always disconnecting I don't know. In my case it did "work" as documented but only produced static.
i updated the branch and the connected_msbc log is fixed so thank you. @esp-qing
However, i followed this mic testing tutorial (it uses bluetooth) and it worked so idk why the esp idf one always disconnnected. do i need a specific application in my phone so that my mic can be heard from the phone? i use "Bluetooth Audio Connect Widget"
Generally, there is no need to install app on the phone.
From your debug logs, the error code is 0x13. In the Bluetooth Core Specification, the user on the remote device either terminated the connection or stopped broadcasting packets. Because the bluetooth is disconnected, the audio is disconnected. There are many reasons for the Bluetooth disconnection. The easiest way is to try a different phone?
(Regarding the INMP441, you can refer to jtwaleson's comments.)
Having done a lot of research I can tell you that currently INMP441 will not work with HFP_HF in PCM mode. INMP441 uses Philips / 1 bit-shift / i2s the timing format, instead of the "normal" / left-aligned / "MSB" timing format. See here: https://github.com/espressif/esp-idf/issues/13738#issuecomment-2423758387
There are many reasons for the Bluetooth disconnection. The easiest way is to try a different phone?
I see, sadly i need to use INMP441 because of the space constraint for my project. I haven't tried a different phone, but since i need to use INMP441, would the outcome be the same? And Android use HFP v1.5, which means there's no wide band speech support. So i can't use mSBC audio path. But i have a question, the mic testing tutorial that i mentioned is using bluetooth serial, what is the difference between them and HFP? And what is the downsides of using bluetooth serial over HFP? Thank you.
Answers checklist.
General issue report
SETUP ESP32-WROVER-E INMP441 ESP-IDF v5.3 Eclipse IDE Redmi Note 7
So i'm trying to run the hfp_hf example to stream my audio to my smartphone using bluetooth. I've already set my audio path configurations to PCM. I've set my INMP441 pins as: SD: GPIO_OUTPUT_PCM_DOUT (26) SCK: GPIO_OUTPUT_PCM_CLK_OUT (5) WS: GPIO_OUTPUT_PCM_FSYNC (25) L/R: Not connected
The bluetooth connection between my ESP32 and smartphone was successful. But when i try to connect audio, the first audio state was connected, then connected_msbc, and then it disconnected. Since i've set my audio path to PCM, i have no idea why the logs are stating connected_msbc. I tried #14231 by
and the connected_msbc logs are gone, but the disconnecting issue still persist.
The debug logs are as follow [idf.py monitor] `Executing action: monitor Serial port COM6 Connecting..... Detecting chip type... Unsupported detection protocol, switching and trying again... Connecting...... Detecting chip type... ESP32 Running idf_monitor in directory C:\Users\mbran\workspace\hfp_hf Executing "C:\Espressif\python_env\idf5.3_py3.11_env\Scripts\python.exe C:\Espressif\frameworks\esp-idf-v5.3\tools/idf_monitor.py -p COM6 -b 115200 --toolchain-prefix xtensa-esp32-elf- --target esp32 --revision 0 C:\Users\mbran\workspace\hfp_hf\build\hfp_hf.elf --force-color -m 'C:\Espressif\python_env\idf5.3_py3.11_env\Scripts\python.exe' 'C:\Espressif\frameworks\esp-idf-v5.3\tools\idf.py'"... --- WARNING: GDB cannot open serial ports accessed as COMx --- Using \.\COM6 instead... --- esp-idf-monitor 1.4.0 on \.\COM6 115200 --- --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H --- ets Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0030,len:7176 load:0x40078000,len:15564 ho 0 tail 12 room 4 load:0x40080400,len:4 0x40080400: _init at ??:?
load:0x40080404,len:3904 entry 0x40080640 I (31) boot: ESP-IDF v5.3 2nd stage bootloader I (31) boot: compile time Oct 8 2024 21:47:17 I (31) boot: Multicore bootloader I (35) boot: chip revision: v3.1 I (39) boot.esp32: SPI Speed : 40MHz I (44) boot.esp32: SPI Mode : DIO I (48) boot.esp32: SPI Flash Size : 2MB I (53) boot: Enabling RNG early entropy source... I (58) boot: Partition Table: I (62) boot: ## Label Usage Type ST Offset Length I (69) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (76) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (84) boot: 2 factory factory app 00 00 00010000 00100000 I (91) boot: End of partition table I (96) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=21e94h (138900) map I (152) esp_image: segment 1: paddr=00031ebc vaddr=3ffbdb60 size=04c88h ( 19592) load I (159) esp_image: segment 2: paddr=00036b4c vaddr=40080000 size=094cch ( 38092) load I (174) esp_image: segment 3: paddr=00040020 vaddr=400d0020 size=7b634h (505396) map I (348) esp_image: segment 4: paddr=000bb65c vaddr=400894cc size=0ded0h ( 57040) load I (382) boot: Loaded app from partition at offset 0x10000 I (382) boot: Disabling RNG early entropy source... I (394) cpu_start: Multicore app I (403) cpu_start: Pro cpu start user code I (403) cpu_start: cpu freq: 160000000 Hz I (403) app_init: Application information: I (406) app_init: Project name: hfp_hf I (411) app_init: App version: 1 I (415) app_init: Compile time: Oct 8 2024 22:35:03 I (421) app_init: ELF file SHA256: a5455f40f... I (426) app_init: ESP-IDF: v5.3 I (431) efuse_init: Min chip rev: v0.0 I (436) efuse_init: Max chip rev: v3.99 I (440) efuse_init: Chip rev: v3.1 I (446) heap_init: Initializing. RAM available for dynamic allocation: I (453) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM I (459) heap_init: At 3FFB6BF8 len 00001408 (5 KiB): DRAM I (465) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM I (471) heap_init: At 3FFC8268 len 00017D98 (95 KiB): DRAM I (477) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM I (483) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (490) heap_init: At 4009739C len 00008C64 (35 KiB): IRAM I (498) spi_flash: detected chip: generic I (501) spi_flash: flash io: dio W (504) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header. I (518) coexist: coex firmware version: dab85ae96 I (524) main_task: Started on CPU0 I (534) main_task: Calling app_main() I (544) BTDM_INIT: BT controller compile version [f021fb7] I (544) BTDM_INIT: Bluetooth MAC: a8:42:e3:ae:78:62 I (554) phy_init: phy_version 4830,54550f7,Jun 20 2024,14:22:08 I (1164) BT_HF: Starting device discovery... I (1184) BT_RFCOMM: RFCOMM_CreateConnection() BDA: ff-ff-ff-ff-ff-ff I (1184) BT_RFCOMM: RFCOMM_CreateConnection(): scn:1, dlci:2, is_server:1 mtu:256, p_mcb:0x0 I (1184) BT_RFCOMM: RFCOMM_CreateConnection(): scn:1, dlci:2, is_server:1 mtu:256, p_mcb:0x0, p_port:0x3ffc595c I (1204) BT_RFCOMM: PORT_SetEventMask() handle:2 mask:0x1 I (1204) BT_RFCOMM: PORT_SetEventCallback() handle:2 I (1214) BT_HF: event: 10 I (1214) BT_HF: event: 10 I (1224) gpio: GPIO[5]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 I (1224) BT_HF: ESP_BT_GAP_DISC_STATE_CHANGED_EVT I (1234) gpio: GPIO[25]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 I (1244) gpio: GPIO[26]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 I (1254) gpio: GPIO[35]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 I (1264) gpio: GPIO[19]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 I (1274) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 I (1274) gpio: GPIO[22]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0`
[ESP32 and smartphone are connected] I (1464) main_task: Returned from app_main() hfp_hf> I (14034) BT_HF: ESP_BT_GAP_DISC_STATE_CHANGED_EVT W (15544) BT_HCI: hcif conn complete: hdl 0x80, st 0x0 I (15554) BT_HF: event: 16 W (15564) BT_HCI: hcif link supv_to changed: hdl 0x80, supv_to 8000 I (15924) BT_HF: event: 21 I (16044) BT_RFCOMM: PORT_CheckConnection() handle:2 W (16054) BT_APPL: new conn_srvc id:27, app_id:1 I (16054) BT_RFCOMM: PORT_WriteData() max_len:12 I (16064) BT_HF: APP HFP event: CONNECTION_STATE_EVT I (16064) BT_HF: --connection state connected, peer feats 0x0, chld_feats 0x0 I (16104) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (16104) BT_RFCOMM: PORT_WriteData() max_len:11 I (16114) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (16124) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (16124) BT_RFCOMM: PORT_WriteData() max_len:10 I (16144) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (16154) BT_RFCOMM: PORT_WriteData() max_len:9 I (16154) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (16844) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (16844) BT_RFCOMM: PORT_WriteData() max_len:16 I (16854) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (16854) BT_HF: APP HFP event: CALL_IND_EVT I (16864) BT_HF: --Call indicator NO call in progress I (16864) BT_HF: APP HFP event: CALL_SETUP_IND_EVT I (16864) BT_HF: --Call setup indicator NONE I (16874) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (16884) BT_RFCOMM: PORT_WriteData() max_len:10 I (16884) BT_HF: APP HFP event: NETWORK_STATE_EVT I (16894) BT_HF: --NETWORK STATE unavailable I (16894) BT_HF: APP HFP event: SIGNAL_STRENGTH_IND_EVT I (16904) BT_HF: -- signal strength: 0 I (16914) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (16914) BT_RFCOMM: PORT_WriteData() max_len:47 I (16924) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (16924) BT_HF: APP HFP event: ROAMING_STATUS_IND_EVT I (16934) BT_HF: --ROAMING: inactive I (16934) BT_HF: APP HFP event: BATTERY_LEVEL_IND_EVT I (16944) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (16944) BT_RFCOMM: PORT_WriteData() max_len:10 I (16954) BT_HF: --battery level 2 I (16954) BT_HF: APP HFP event: CALL_HELD_IND_EVT I (16964) BT_HF: --Call held indicator NONE held I (16964) BT_HF: APP HFP event: CONNECTION_STATE_EVT I (16974) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (16984) BT_RFCOMM: PORT_WriteData() max_len:10 I (16984) BT_HF: --connection state slc_connected, peer feats 0xf67, chld_feats 0x2b I (17004) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 W (17014) BT_APPL: bta_hf_client_send_at: No service, skipping 11 command I (17014) BT_RFCOMM: PORT_WriteData() max_len:9 I (17064) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (17074) BT_RFCOMM: PORT_WriteData() max_len:10 I (17124) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 W (23254) BT_HCI: hci cmd send: sniff: hdl 0x80, intv(400 800) W (23324) BT_HCI: hcif mode change: hdl 0x80, mode 2, intv 800, status 0x0 I (23334) BT_HF: ESP_BT_GAP_MODE_CHG_EVT mode:2
[connect audio] connect audio I (25434) BT_RFCOMM: PORT_WriteData() max_len:7 I (25434) BT_HF: APP HFP event: AUDIO_STATE_EVT I (25434) BT_HF: --audio state connecting hfp_hf> W (26644) BT_HCI: hcif mode change: hdl 0x80, mode 0, intv 0, status 0x0 I (26644) BT_HF: ESP_BT_GAP_MODE_CHG_EVT mode:0 I (26664) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (26674) BT_RFCOMM: PORT_WriteData() max_len:9 I (26674) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (26684) BT_RFCOMM: PORT_ReadData() handle:2 max_len:512 I (26694) BT_HF: APP HFP event: AUDIO_STATE_EVT I (26694) BT_HF: --audio state connected_msbc W (26714) BT_HCI: hcif disc complete: hdl 0x180, rsn 0x13 I (26724) BT_HF: APP HFP event: AUDIO_STATE_EVT I (26724) BT_HF: --audio state disconnected W (33734) BT_HCI: hcif mode change: hdl 0x80, mode 2, intv 798, status 0x0 I (33744) BT_HF: ESP_BT_GAP_MODE_CHG_EVT mode:2