How to Produce Sound With Arduino and Esp32 (Multi-core) (Tutorial)
by s4mir32N16 in Circuits > Arduino
170 Views, 1 Favorites, 0 Comments
How to Produce Sound With Arduino and Esp32 (Multi-core) (Tutorial)
Always wanted to make your arduino talk,play some music,no matter what duration?
We have the solution,Plus the esp32 Port of it (Multi-core versions)
How does Audio work?
The WAV file format, developed by IBM and Microsoft, was introduced in 1991. This format is based on the RIFF (Resource Interchange File Format) standard, which is a generic header file format used to store data in chunks. The WAV file, a subtype of RIFF, is named after sound waves, as it is used for storing audio data.
The WAV file format includes a header that contains information about the file, such as its size, duration, sample rate, and bit depth. One drawback of WAV files is their large size, as they are typically uncompressed.
In contrast, the MP3 format, which was also introduced in 1991, is a compressed audio format that reduces file size significantly compared to WAV files. The MP3 format was developed by the Fraunhofer Society in Germany, led by Karlheinz Brandenburg. Unlike WAV files, MP3 files use compression algorithms to make audio files much smaller while maintaining reasonable sound quality.
how each one can output Audio?
When its on arduino,the audio output acts as a PCM Audio using the PWM Output (Pulse width Modulation) that
uses changing power at high speeds to produce a audio using its 8-bit unsigned data At mono output,so remember to always use the PWM Pins when playing sound at your arduino
On esp32 is very different,it uses I2S Sound (Inter-IC Sound),so you can place any digital pin on your model
As I2S Have PCM Data output,it can perfectly act as a audio using 16-bit signed data,Also the fact that can
Run Stereo Output
if you still got issues on your audio getting a too low volume,try to use EQ And filters > Bass and treble then you can change the volume up
until you get the perfect audio you need,Also minor notice if you put max volume into your esp32 it will sound noisy like a tv static sound
if still you did not like how it sounded,you can get a simpler alternative that have a proper amplifier,Sounds more louder,and more pratical to use
the DFplayer module may reach your likings,if you want to see this guide on how to set up this module,check this Guide
Quick notice : To make this work correctly on esp32 models,you must have the ESP32 2.0.14 Version,And This library only works on multi-core ESP32 chips like the ESP32-S3. It does not work on the ESP32-S2 or the ESP32-C3
Supplies
Boards
- Arduino uno or Esp32 (Multi-core)
Writing/reading
- Sd card adapter
- SD card at max of 32GB
- Microsd card module
Mounting
This is for default arduino uno pins,to find out your sd card pin,Check on this Guide
Sd card
- Gnd on -
- VCC on +
- MISO at D12
- MOSI at D11
- SCK at D13
- CS at pin D10
Audio
- Audio output at D9
- Audio Gnd on -
If you are using arduino uno use this WAV Format
8 Bit pcm
16000hz
Final Results and Conclusions
After mounting and uploading to the sketch you are ready to make lots of things like a Audio alarm system,Music player,and many others
If you want to be able to connect a simple amplifier (volume control) use a potentiometer at the audio output