justLV / onju-voice

A hackable AI home assistant platform
MIT License
1.31k stars 70 forks source link

Cannot get the speaker to work in ESP-IDF #57

Open imalros opened 5 months ago

imalros commented 5 months ago

I am trying to port the provided firmware to ESP-IDF but it seems like I am not able to get the speaker to work.

First off, I wanted to make sure if the code is alright, so I recreated the circuit (or let's say the important parts of the circuit) on a breadboard with ESP32-S3-DevkitC at its core, and seems like the speaker works just fine when using the wired up circuit. But when I flash the same binary onto the custom PC, for some reason the speaker does not play the sound. I noticed that there is a variable defined without any documentation in the original firmware called SPEAKER_EN, and it is set to output high, but never used. Does this have anything to do with the speaker not playing what's been written on I2S TX channel when the PCB is used?

imalros commented 5 months ago

After looking through the schematics, I found out that GPIO_NUM_21 is connected to the MAX98357AETE+ 's SD_MODE pin. According to the datasheet, if SD_MODE is LOW, the chip will change state to shutdown mode, and if it is HIGH, the chip selects the left channel (the chip is a mono chip). I now set the GPIO_NUM_21 to high and output mode, still no sound comes out of the speaker. It is gonna be a loooong night.

Xe138 commented 1 month ago

Not sure if you got this working, but I was able to get the speaker working using ESPHome using the following pins: