This project uses a Dasduino CONNECTPLUS (ESP32), an Ultrasonic Distance Sensor, and a MAX98357A I²S Audio Amplifier to create an intelligent sound warning system.
When the ultrasonic sensor detects an object at approximately 40 cm (±3 cm) for more than 5 seconds, it plays a custom audio file (done.wav) from a microSD card through two connected speakers.
The project can also be manually controlled over the Serial Monitor, allowing you to:
- Play the sound once
- Enable/disable looping playback
- Enable/disable ultrasonic detection
- Adjust audio volume in real time
It’s ideal for industrial automation, machine status indication, or any system where a clear, audible feedback signal is required.
- Dasduino CONNECTPLUS
- Ultrasonic Distance Sensor (easyC)
- MAX98357A I²S Audio Amplifier
- Speaker 0.5 W / 8 Ω
- microSD Card Module
- microSD card (formatted FAT32) with a file named
/done.wav
- Arduino IDE
- ESP32-audioI2S Library
- Ultrasonic Distance Sensor easyC Library
- Built-in:
SD.h,FS.h
- If you haven’t already, install Arduino IDE
- Download this repository and extract it
- Open the Arduino sketch:
audio-amplifier-warning-sensor-project/audio-amplifier-warning-sensor-project.ino - Open the Boards Manager and search for ESP32 by Espressif Systems, then install it
- Under Tools → Board, select ESP32 Dev Module and the correct serial port
- Set:
- PSRAM: Enabled
- Partition Scheme: No OTA (Large APP)
- Install all of the libraries listed under Software Requirements
- Place your audio file on a FAT32-formatted SD card and rename it to
done.wav
(You can use any.wavfile you like — a beep, tone, alert, or even a short melody. Just make sure it’s 16-bit PCM, 44.1 kHz.) - Wire the components as described below and upload the sketch
No credentials or additional configuration are needed for this project.
- Upon startup, the serial monitor (115200 baud, No line ending) displays available commands.
- You can control the system using the following single-character commands:
Command Action pPlay the sound once lStart loop playback (every 5 seconds) sStop loop playback uEnable ultrasonic detection zDisable ultrasonic detection 0–21Set volume (0 = mute, 21 = max) - When ultrasonic detection is active and an object stays at ~40 cm ±3 cm for 5 seconds, the system plays
/done.wav. - You can monitor the measured distance in real time through the serial output.
- Adjust volume or stop/start detection at any time.
- Replace
done.wavanytime to change the sound the device plays.
| Component | Pin on Dasduino | Notes |
|---|---|---|
| MAX98357A VCC | 5V | Power |
| MAX98357A GND | GND | Common ground |
| MAX98357A BCLK | GPIO26 | I²S bit clock |
| MAX98357A LRCLK | GPIO25 | I²S left/right clock |
| MAX98357A DIN | GPIO27 | I²S audio data |
| microSD VCC | 3.3V (or 5V if supported) | Power |
| microSD GND | GND | Common ground |
| microSD MOSI | GPIO23 | SPI data output |
| microSD MISO | GPIO19 | SPI data input |
| microSD SCK | GPIO18 | SPI clock |
| microSD CS | GPIO33 | Chip select |
| Ultrasonic (easyC) | Qwiic/easyC port | Uses I²C (GPIO21/22) |
| Speakers | L+, L– / R+, R– | Connect to amplifier outputs |
At Soldered, we design and manufacture a wide selection of electronic products to help you turn your ideas into acts and bring you one step closer to your final project. Our products are intended for makers and crafted in-house by our experienced team in Osijek, Croatia. We believe that sharing is a crucial element for improvement and innovation, and we work hard to stay connected with all our makers regardless of their skill or experience level. Therefore, all our products are open-source. Finally, we always have your back. If you face any problem concerning either your shopping experience or your electronics project, our team will help you deal with it, offering efficient customer service and cost-free technical support anytime. Some of those might be useful for you:
Soldered invests vast amounts of time into hardware & software for these products, which are all open-source. Please support future development by buying one of our products.
This repository is under the MIT license. Long story short: use these open-source files for any purpose you want, as long as you apply the same open-source licence to it and disclose the original source.
No warranty — all designs in this repository are distributed in the hope that they will be useful, but they are provided “AS IS” without warranty of any kind.
The entire quality and performance of what you do with the contents of this repository are your responsibility.
And thank you from your fellow makers at Soldered Electronics.
