WAVe file player

Hi all.
I know there are other solutions to get a small audio file to play from Hubitat but I wanted something that worked in isolation (no dependance on cloud services) and didn't require my home audio to be interrupted or modified.
Thanks to the ST_Anything driver from ogiewon, and some hints from Phil Schatzmann I put together a small ESP32 using Arduino to play sounds for my home automation system.
A doorbell is one of them, but I can record anything to a wave file and play them on demand. It needs an external audio amp but otherwise is completely self contained.
I record my sounds on WAV format to an SD Card which is loaded into an ESP32-Cam module. This module has the SD Card slot on it already, and an external RAM that I use to cache the WAV files. This allows them to be updated without interrupting the system.
The ST_Anything links this sound player as a dimmer light, so sending a value 1 plays sound 1, etc..
In theory it could have 100 sounds but I'm only using about 10. Total PSRAM storage limits the total length of WAV files.
Sound is generated mono only at this stage due to one of the DAC outputs being used by the ESP32-CAM camera interface. Might still be possible to do stereo but my doorbell doesn't really need it so I didn't try.
Of course it could be modified to play MP3 but that's a later task.
If anyone is interested I will post the code when I'm back from holidays.
Big thanks to Phil and ogiewon for their efforts, ESPecially for the ST_Anything development.

4 Likes