Pi Zero – Motion Based Audio Player


I wanted to make a device that would play audio when motion was detected.

Materials used.

Battery Powered Speaker
UnicornRaspberry Pi 2b+ (for initial testing of code)
Raspberry Pi Zero (for permanent build)

 

 

 

 

 

5V PIR Sensor
raspberry-pi-gpio-controls
I followed these instructions as I experimented with Python and integrating the PIR sensors.

Arduino boards could  accomplish this task but I have plans of expanding functions like streaming audio/video surveillance over wifi.

This functioned perfectly on a Raspberry Pi 2 B+ with its integrated audio output port using a 3.5MM generic audio cable.

I decided on implementing this through a Raspberry Pi Zero for its low power consumption.
The immediate obstacle was getting audio output from the board as there is no 3.5MM jack.
raspberryPiZero1
I decided to remove the 3.5MM jack from the speaker as well and solder wires directly to pads of the speakers board coming from the Pi Zero.

SpeakerWiring
Adding-basic-audio-ouput-to-raspberry-pi-zero
I followed the instructions found on adafruit and successfully configured the pi zero to play audio through the PWM pin out.

In my Python code I decided to use Pygame for the many aspects of control it allows.


The Pi Zero is initially powered from an electrical outlet, then I later integrated the battery to the Zero & PIR sensor.

The last step was to always launch the python script on boot up with the following code.

Leave a Reply

Your email address will not be published. Required fields are marked *