Raspberry Pi based automated audio player. Use it in any room where you want to create an ambiance!
I use this device plays ambiant sounds, such as forest, rain or wind recordings. The audio is started as soon as movement is detected, and ends 30 seconds after the movement stops. Also, the device remain silent at night.
- Raspberry Pi 3B+ or newer, with an adapted power supply
- PIR sensor (for example, BS412)
- Speaker with integrated amplifier (for example, Adafruit STEMMA Speaker)
- A few cables, solder and a soldering iron
- Header socket (2.54 mm pitch) to connect peripherals to the Raspberry Pi. Alternatively, wires can be soldered directly to the board headers, but I would not recommand it.
- 1x 01x01 pin configuration
- 2x 01x02 pins configuration
- An old jack 3.5 mm cable that you are willing to destroy
- A 3D printer
- 3D printing filament (~100g is necessary, depending on your slicing parameters)
- 3x M3 heat set threaded inserts
- 3x M3x5 socket head cap screws
- 8x M2.5x6 socket head cap screws
- Audio files you want to play in .mp3 format
- Flash OS, setup Wifi, user and password (pi, pipipipi), etc.
- Clone git repo in /home/pi/Documents
- Install requirements :
sudo apt install python3-mypackagefor each package - Copy desired audio file(s) in /home/pi/Music
- Disable the HDMI audio so the Jack 3.5 is used by default:
- Edit the configuration file:
sudo nano /boot/config.txt - Add the following:
hdmi_ignore_edid_audio=1 audio_pwm_mode=2 - Save and exit using ctrl + X
- Edit the configuration file:
- Autorun python script at boot using a .desktop file (other methods such as systemd do not work as the desktop env is required to play sound):
- Create the autostart directory:
mkdir -p /home/pi/.config/autostart - Create the file:
sudo nano /home/pi/.config/autostart/ambianceur.desktop - Enter the following in the file:
[Desktop Entry] Type=Application Exec=python /home/pi/Documents/Ambianceur/main.py - Save and exit using ctrl + X
- Create the autostart directory:
Any 3D printer can be used to print the case. I used an Ender 3 V3 with PETG filament.
- Download the 3D files in .stl format located in Ambianceur/3D/
- Open your slicing software and import the files
- Slice the file using your prefered parameters. I used 0.2 mm layer height and 2 wall perimeters.
- Start printing!
Connect as follow:
PIR:
- GND (VSS) and ONTIME -> 01x01 header socket. Will connect to pin 20 of Raspberry Pi (GND)
- VDD -> one pin of 01x02 header socket #1. Will connect to pin 17 of Raspberry Pi (3.3V)
- REL -> other pin of 1x02 header socket #1. Will connect to pin 18 of Raspberry Pi (GPIO 24)
Audio amplifier:
- +5V -> one pin of 01x02 header socket #2. Will connect to pin 4 of Raspberry Pi (5V)
- GND -> other pin of 01x02 header socket #2. Will connect to pin 6 of Raspberry Pi (GND)
- Jack 3.5mm GND -> GND pad on audio amplifier
- Jack 3.5mm Signal -> Signal pad on audio amplifier
- Insert PIR sensor in the intended hole. If it is loose, use some glue, tape or similar to keep it in place.
- Screw the audio amplifier board using four M2.5x6 screws.
- Wire everything as explained in the previous section
- Screw the Raspberry Pi using the remaining M2.5x6 screws.
- Plug the power supply to the Raspberry Pi through the intended hole.
- Screw the cover using three M3x5 screws
Plug the power supply into a wall outlet. After less than 5 minutes, the device should be operationnal. Have fun!