Xinyuan-LilyGO / T-Embed

MIT License
86 stars 23 forks source link

Unable to make microphones work - ES7210 #20

Open tfkmuller opened 1 year ago

tfkmuller commented 1 year ago

Hallo,

I love the t-embed board and am able to use all the components successfully in my code. However I have been struggling for weeks to make the microphones work. Can you please provide a simple example just outputting the microphones data to a serial plotter/ console. I am struggling to get the ES7210 properly initialized and using the MCKL in the I2S initialization. Please help, I spent so much time on it and can't get it to work. The included mic example only outputs "0". Thank you.

Best, Tom

lewisxhe commented 1 year ago

I will respond to you after testing on Monday

tfkmuller commented 1 year ago

Thank you Lewis.

I have tried everything and have been unsuccessful for weeks. I am usually using Arduino IDE and I have all components of the board working (except the microphones): I2S sound out through speaker, TFT, SD card, rotary dial and button, leds all work perfectly, but I cant get the microphone to work. When I use VS Code for the supplied Mic example I only get “0” on the serial monitor/ plotter. I think the board is so great and I really would like to use the microphones, but can’t get it to work.

I would be most grateful for a working simple code snipplet just reading the es7210 microphones and outputting it on serial.

Thank you in advance.

Best, Tom

From: Lewis He @.> Date: Sunday, 9 April 2023 at 03:45 To: Xinyuan-LilyGO/T-Embed @.> Cc: Tom @.>, Author @.> Subject: Re: [Xinyuan-LilyGO/T-Embed] Unable to make microphones work - ES7210 (Issue #20)

I will respond to you after testing on Monday

— Reply to this email directly, view it on GitHubhttps://github.com/Xinyuan-LilyGO/T-Embed/issues/20#issuecomment-1501025057, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIBQBR6MDP6HHGQ2CMIX6FLXAIPD7ANCNFSM6AAAAAAWTVO6AU. You are receiving this because you authored the thread.Message ID: @.***>

lewisxhe commented 1 year ago

I have updated the microphone example, which can detect the presence of sound. It can verify whether the board is working properly

https://github.com/Xinyuan-LilyGO/T-Embed/tree/main/example/mic

tfkmuller commented 1 year ago

Hi Lewis,

Thank you so much! It is working and I love that you use VAD. Could I please ask you to extend the code so it records the audio/speech to a file on the SD card. I am using this function to mount the SD card and would like to record speech to it when voice is detected (or the rotary button is pressed hold):

void SD_init() { pinMode(PIN_SD_CS, OUTPUT); digitalWrite(PIN_SD_CS, 1); SD_MMC.setPins(PIN_SD_SCK, PIN_SD_MOSI, PIN_SD_MISO); if (!SD_MMC.begin("/sdcard", true)) { Serial.println("Card Mount Failed"); return; } uint8_t cardType = SD_MMC.cardType();

if (cardType == CARD_NONE) { Serial.println("No SD card attached"); return; } delay(500); }

Thank you in advance for your help. You are great! Thank you.

Best, Tom

From: Lewis He @.> Date: Monday, 10 April 2023 at 02:20 To: Xinyuan-LilyGO/T-Embed @.> Cc: Tom @.>, Author @.> Subject: Re: [Xinyuan-LilyGO/T-Embed] Unable to make microphones work - ES7210 (Issue #20)

I have updated the microphone example, which can detect the presence of sound. It can verify whether the board is working properly

https://github.com/Xinyuan-LilyGO/T-Embed/tree/main/example/mic

— Reply to this email directly, view it on GitHubhttps://github.com/Xinyuan-LilyGO/T-Embed/issues/20#issuecomment-1501276182, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIBQBRYUO7LSGDWZLSNFF2LXANN63ANCNFSM6AAAAAAWTVO6AU. You are receiving this because you authored the thread.Message ID: @.***>

tfkmuller commented 1 year ago

Dear Lewis,

One more thing. Not sure why, but using your code somehow doesn’t let me use the rotary button anymore. I used to access the button vie the OneButton library without any problems, but somehow this doesn’t work anymore using your code. It seems PIN 0 (rotary button/boot button) can’t be used anymore. I did attach an external button to PIN 16 and OneButton library works with this one.

include "OneButton.h"

define ROTARY_BUTTON 0

OneButton button(ROTARY_BUTTON, true);

void setup() {

Serial.begin(115200); button.attachClick(click1); }

void loop() { button.tick(); } void click1() { Serial.println("Button pressed"); }

The above code doesn’t work anymore in combination with the MIC example you posted. Could you please check why this is the case. Thank you.

Best, Tom From: Tom Mueller @.> Date: Tuesday, 11 April 2023 at 09:28 To: Xinyuan-LilyGO/T-Embed @.>, Xinyuan-LilyGO/T-Embed @.> Cc: Author @.> Subject: Re: [Xinyuan-LilyGO/T-Embed] Unable to make microphones work - ES7210 (Issue #20) Hi Lewis,

Thank you so much! It is working and I love that you use VAD. Could I please ask you to extend the code so it records the audio/speech to a file on the SD card. I am using this function to mount the SD card and would like to record speech to it when voice is detected (or the rotary button is pressed hold):

void SD_init() { pinMode(PIN_SD_CS, OUTPUT); digitalWrite(PIN_SD_CS, 1); SD_MMC.setPins(PIN_SD_SCK, PIN_SD_MOSI, PIN_SD_MISO); if (!SD_MMC.begin("/sdcard", true)) { Serial.println("Card Mount Failed"); return; } uint8_t cardType = SD_MMC.cardType();

if (cardType == CARD_NONE) { Serial.println("No SD card attached"); return; } delay(500); }

Thank you in advance for your help. You are great! Thank you.

Best, Tom

From: Lewis He @.> Date: Monday, 10 April 2023 at 02:20 To: Xinyuan-LilyGO/T-Embed @.> Cc: Tom @.>, Author @.> Subject: Re: [Xinyuan-LilyGO/T-Embed] Unable to make microphones work - ES7210 (Issue #20)

I have updated the microphone example, which can detect the presence of sound. It can verify whether the board is working properly

https://github.com/Xinyuan-LilyGO/T-Embed/tree/main/example/mic

— Reply to this email directly, view it on GitHubhttps://github.com/Xinyuan-LilyGO/T-Embed/issues/20#issuecomment-1501276182, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIBQBRYUO7LSGDWZLSNFF2LXANN63ANCNFSM6AAAAAAWTVO6AU. You are receiving this because you authored the thread.Message ID: @.***>

lewisxhe commented 1 year ago

When the microphone is enabled, GPIO0 will not be available. There is no way to solve this problem, and I can't find out why in the existing manual documents. Regarding audio recording, you can refer to this repository https://github.com/RafigRzayev/Audio_Recording_to_WAV/blob/main/pdm_mic/pdm_mic.ino

jalmince commented 1 year ago

Hi Tom, I 'd love to know if you managed to record the mic on card ?! I am struggling... no success. I try the code code Lewis pointed you to, adapted the pins from the mic example in the git, but my device crashes in I2S_Init() after i2s_set_pin(....) with "Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled." followed by mem dumps ( useless for me..) Ive spent all day on that (...) untill I decided to ask for help !
cheers, Jean-Paul

tfkmuller commented 1 year ago

Hi Jean Paul,

Great to hear from you. Yes, I did get it to work (a little bit). Couple of things:

Best, Tom From: jalmince @.> Date: Saturday, 15 April 2023 at 20:36 To: Xinyuan-LilyGO/T-Embed @.> Cc: Tom @.>, Author @.> Subject: Re: [Xinyuan-LilyGO/T-Embed] Unable to make microphones work - ES7210 (Issue #20)

Hi Tom, I 'd love to know if you managed to record the mic on card ?! I am struggling... no success. I try the code code Lewis pointed you to, adapted the pins from the mic example in the git, but my device crashes in I2S_Init() after i2s_set_pin(....) with "Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled." followed by mem dumps ( useless for me..) Ive spent all day on that (...) untill I decided to ask for help ! cheers, Jean-Paul

— Reply to this email directly, view it on GitHubhttps://github.com/Xinyuan-LilyGO/T-Embed/issues/20#issuecomment-1509939854, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIBQBR3NS7ITOMV3KQUOVKDXBL2DFANCNFSM6AAAAAAWTVO6AU. You are receiving this because you authored the thread.Message ID: @.***>

jalmince commented 1 year ago

Hi Tom ! thnks for your answer. Actually I had got it to work in the mean time ! ( another long night ..) For the last issue ( slow playing back), you have to multiply by 2 for the data_size used in the loop populating the wav file : uint32_t data_size = 2 SAMPLE_RATE I2S_BITS_PER_SAMPLE_16BIT * duration / 8; May be had you figured it out as well in the mean time ?! best, JPaul

PS: not quite sure the git is the right place to exchange ! and didn t get any email to warn me you had replied..( may be something I should set up ?) I d happilly carry on through any other media if you have any idea