atomic14 / voice-controlled-robot

A voice-controlled robot using the ESP32 and TensorFlow Lite
MIT License
165 stars 53 forks source link

Dear Atomic14, I have some issue. #7

Closed fabiodavide97 closed 3 years ago

fabiodavide97 commented 3 years ago

When I run the code, appear this problem in Serial Monitor and the mic doesn't listen:

E (22702) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time: E (22702) task_wdt: - IDLE0 (CPU 0) E (22702) task_wdt: Tasks currently running: E (22702) task_wdt: CPU 0: Command Detect E (22702) task_wdt: CPU 1: loopTask

Can you help me, please ?

cgreening commented 3 years ago

Hey Fabio,

I'll take a look. Have you made any modifications to the code?

Thanks Chris

fabiodavide97 commented 3 years ago

I only changed the microphone connection pin: sck ---> GPIO25 WS ----> GPIO33 SD ----> GPIO32 VDD --->3.3V GND ---> GND

cgreening commented 3 years ago

Hmm, that shouldn't make any difference. Let me run it up locally and see if something has changed with the underlying Arduino frameworks.

fabiodavide97 commented 3 years ago

could it be a microphone problem? I use an INMP441.

cgreening commented 3 years ago

It should matter - though I guess if there's weird data coming from the microphone it could trigger some odd behaviour.

In the code, we see the watch dog timeout to 10 seconds so it really shouldn't be triggering at all.

  // make sure we don't get killed for our long running tasks
  esp_task_wdt_init(10, false);

This is what you should see on the output (I'm running this with no microphone connected at all).

Average detection time 103ms
Average detection time 103ms
Average detection time 103ms
Average detection time 103ms
Average detection time 103ms
Average detection time 103ms
Average detection time 103ms
Average detection time 103ms
cgreening commented 3 years ago

I've added a vTaskDelay to the loop function - I'm not sure if will help as I can't create the issue - I'll do some more investigation this evening.

fabiodavide97 commented 3 years ago

Starting up Loading model 12 bytes lost due to alignment. To avoid this loss, please make sure the tensor_arena is 16 bytes aligned. Used bytes 22644

Output Size 1

Created Neral Net m_pooled_energy_size=43 Created audio processor Starting i2s E (22715) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time: E (22715) task_wdt: - IDLE0 (CPU 0) E (22715) task_wdt: Tasks currently running: E (22715) task_wdt: CPU 0: Command Detect E (22715) task_wdt: CPU 1: IDLE1 Average detection time 155ms E (32715) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time: E (32715) task_wdt: - IDLE0 (CPU 0) E (32715) task_wdt: Tasks currently running: E (32715) task_wdt: CPU 0: Command Detect E (32715) task_wdt: CPU 1: IDLE1 E (42715) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time: E (42715) task_wdt: - IDLE0 (CPU 0) E (42715) task_wdt: Tasks currently running: E (42715) task_wdt: CPU 0: Command Detect E (42715) task_wdt: CPU 1: IDLE1 Average detection time 155ms E (52715) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time: E (52715) task_wdt: - IDLE0 (CPU 0) E (52715) task_wdt: Tasks currently running: E (52715) task_wdt: CPU 0: Command Detect E (52715) task_wdt: CPU 1: IDLE1

This is the Serial Monitor.

cgreening commented 3 years ago

I think since the device is not restarting you can probably ignore the message. Though I'm not sure why you are seeing it with the watchdog pretty much disabled.

Onto your microphone issue - can you check that in the config.h file the line

#define USE_I2S_MIC_INPUT

Is not commented out. I noticed in the previous code that it was commented out which would switch the device into using the ADC instead of the I2S microphone.

cgreening commented 3 years ago

Also, your detection time seems to be very slow. What device are you using?

fabiodavide97 commented 3 years ago

I'm using esp32

cgreening commented 3 years ago

Which dev board are you using?

fabiodavide97 commented 3 years ago

16230692427727644901341176130416

cgreening commented 3 years ago

Looks pretty standard. So there are a couple of places that you can debug your microphone.

In CommandDetector.cpp you can try logging out the value of best_score and best_index just after line 96.

In AudioProcessor.cpp you could log out the max value you are getting from the microphone - you can log out the value of max on line 114 and see if it changes when you speak into the microphone.

To really test it, you could try one of my other projects - the simplest one is probably https://github.com/atomic14/ICS-43434-breakout-board it hs a server that the samples are sent to so you can load into something like Audacity - or even just look at the data using hexdump to see if it has non zero values.

You can also just Serial print the values coming from the microphone.

cgreening commented 3 years ago

I've tested the code locally here and all seems well, so I think your first step would be to confirm the microphone is working as expected.

cgreening commented 3 years ago

I've created a really simple test sketch that you can use to test your microphone - let me know how you get on: https://github.com/atomic14/esp32-i2s-mic-test

fabiodavide97 commented 3 years ago

dear Atomic 14 the problem is the microphone because the code generates this waveform. it does not detect sound waves. I don't know how to fix it and hope you can help me. Immagine 2021-06-07 212840

cgreening commented 3 years ago

Double-check the wiring of your microphone - is it definitely wired up correctly?

Make sure the L/R pin is connected to GND.

If you draw out your connections I can double-check them for you.

cgreening commented 3 years ago

Actually, I get exactly what you are seeing when the SD line is disconnected.

fabiodavide97 commented 3 years ago

Yes, the pin is correctly wireds up

fabiodavide97 commented 3 years ago

Dear Atomic 14 finally the code works. The problem was the microphone. Some pins were not soldered well and therefore made no contact. Thank you so much for helping me.

fabiodavide97 commented 3 years ago

Dear Atomic 14, I would like to ask you something else. I have 2 DC motors connected to the L298N module. How can I modify the code to make them work?

cgreening commented 3 years ago

Take a look here: https://github.com/atomic14/voice-controlled-robot/issues/5#issuecomment-855772115