Picture Holder With Built-in Speaker

by CJA3D in Circuits > Speakers

1559 Views, 7 Favorites, 0 Comments

Picture Holder With Built-in Speaker

Picture/Post card holder with a Built-in Speaker
PiSpeakerCircuit.png
PiSpeaker,webapp.JPG
LEDStipOn.jpg
PiSpeaker_LEDPhotoHolder.jpg

Here is a great project to undertake over the weekend, if you want to make you own speaker which can hold pictures/post cards or even you to-do list. As part of the build we are going to use a Raspberry Pi Zero W as the heart of the project, and an I2S class D mono amplifier and 4 ohms speaker, to play our favourite tunes !! And I also added an LED strip just below the picture/post card holder so that you can see it glow at night.

In my case, I have a mp3 songs that I have been collecting over the years, which I have download to the SD card on my Pi and running a software called Mopidy, which is an extensible music server written in Python. And you can play songs using a web browser on your mobile/tablet/laptop as you see in the video.

And I made two version of the speaker, a simple version with a green front and an Instructable version for all you folks that love instructables.com.

In addition, if you have your song collection online on Spotify, SoundCloud or Google Play Music you an install an mopidy extension to play songs from your collection in addition to the songs on the Pi.

Things You'll Need to Complete the Build

electronicComponents.jpg

Here are the list of electronic components you will need

In addition, you will need 3D filament and a 3D printer to print the STL files attached in the steps below

Tools you'll need

  • Hot Glue sticks and gun
  • 3D Printer
  • Xacto Knife
  • Soldering Iron and solder

3D Printing the STL Files

3DPrintedParts.jpg
3DPrintingBase.jpg
3DprintingSpeakerGrid.jpg
3Dprinted_LedStrip.jpg

Download the STL files attached and using 3D printing software slice and 3D print the files.If you don't have a 3D printer handy you can use one at your local maker club or library or use a 3D printing service like 3D hubs.

In my case, I printed the STl files using the Flashforge creator pro and 1.75 mm PLA to print. In addition for slicing I am using Slic3r with the layer height set to 0.3mm and fill density to 25 %.

For the TopLEDstripPicture.STL file you will need translucent PLA filament, so that the colour from the LED strip can diffuse

Connecting the LED Strip to the Pi Zero W

Pi_LEDStrip.jpg
APA102Testing.jpg

Solder 4 female jumper wires to the LED strip, and here are circuit connection for the APA102 LED strip to the Raspberry Pi zero W

  • Power to pin 2 on the Pi (5V Power)
  • GND to pin 6 on the Pi GND
  • Data to pin 16
  • Clock to pin 18

Once done, using your computer flash the latest version of Rasbian-lite img on an SD card (Download link for the img file https://www.raspberrypi.org/downloads/raspbian/). And then add the SD card to the Raspberry Pi and connect your Pi to the your WiFi router and make a note of the IP address, then SSH into your Pi

Start by running the two commands below to update and upgrade the packages on the Pi.

sudo apt-get update  
sudo apt-get upgrade

Now, install the blinkt package written by the awesome folks at Pimoroni. And then get rainbow.py example from blinkt github repo using wget.

sudo apt-get install python-blinkt
sudo wget  https://raw.githubusercontent.com/pimoroni/blinkt... 

And then run the python program with the command below, and you should see your LED strip cycle through colours as shown in the third picture above.

sudo python rainbow.py

Connecting the I2S Amp to the Pi Zero W

Pi_LEDStrip_Speaker.jpg
alsamixer.png
speaker-test.png

Solder the header pins on the Raspberry Pi Zero W and and also solder the speaker to the +ve and -ve on the Adafruit MAX98357 I2S Class-D amplifier.

And here are the pin connections between the Raspberry Pi Zero W and MAX98357 I2S Class-D amplifier.

  • Vin to pin 4 on Pi 5V
  • GND to pin 9 Pi GND
  • DIN to pin 40
  • BCLK to pin 12
  • LRCLK to pin 35

Now to setup and test the Adafruit’s MAX98357 I2S Class-D Mono Amp, follow the guide on the Adafruit Learning system at - https://learn.adafruit.com/adafruit-max98357-i2s-class-d-mono-amp/pinouts?view=all. Basically as part of the setup there is an easy setup and a difficult setup, if you plan to run the easy route just download and run the following shell script

curl -sS <a href="https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/i2samp.sh"> https://raw.githubusercontent.com/adafruit/Raspbe...</a> | bash

To check if the shell script ran successfully, and you are able to hear sound from the speaker run

speaker-test -c2 --test=wav -w /usr/share/sounds/alsa/Front_Center.wav

And to adjust the volume use alsamixer command, in my case I have set it maximum volume.

Setting Up Mopidy to Play Your Favourite Tunes

mopidy_screenshot.png

Now to play you favorite tunes we are going to setup Mopidy and a web client for mopidy, so that you can play your song from your mobile/table. Mopidy plays music from local disk, Spotify, SoundCloud, Google Play Music, and more. You edit the playlist from any phone, tablet, or computer using a range of MPD and web clients.

Now lets install Mopidy run the following command

sudo apt-get install mopidy

for more info check out the documentation at - Installation — Mopidy 2.0.1 documentation

Modify the mopidy.conf to enable the HTTP,MPD and Files sections, here is my mopidy.conf, and my local directory to store musing is /home/pi/Music , so if you plan on using the .conf file below create a “Music” directory in the home folder

sudo nano /etc/mopidy/mopidy.conf

I have attached my mopidy.conf, just in case you would like to make a copy of it.
If you plan on using a web app on the phone/tablet, you will need an http web client, I like the Mopidy-Mobile..

sudo pip install Mopidy-Mobile

To run mopidy on boot run, and restart you pi

sudo systemctl enable mopidy  

sudo reboot

Also, if you plan to load more mp3/.wav files into the Music folder in the future, you will have to run a scan command, so that songs show up in the Mopidy-Mobile client using

sudo mopidyctl local scan

And then use the mobile client open url in your browser on your mobile/computer - http://IpAddressOfPi:6680/ and play your favourite tunes and songs, in my case I have download some creative commons music from the youtube audio library for the video demo, which you see in the screenshot above..

Downloads

Adding the Electronic Components to the 3D Printed Parts.

PiSpeaker_puttingparts.jpg
LEDstipHotglue.jpg
PiSpeaker_frame.jpg
PiSpeakerLEDStrip.jpg

To add the components to the 3D printed parts, the Pi Zero W will snap fit to the base and I used double sided foam tape to hold MAX98357 I2S Class-D amplifier to the base.The other 3D printed parts should snap fit together, but you can use a little hot glue to secure them.

Now, for the Mopidy music player to start every time the Pi is switched on, we can setup Mopidy to ran as a system service, using systemd you can enable the Mopidy service by running:

sudo systemctl enable mopidy

This will make Mopidy automatically start when the system starts. And Mopidy is started, stopped, and restarted just like any other systemd service, using

sudo systemctl start mopidy
sudo systemctl stop mopidy
sudo systemctl restart mopidy

Instructable Version of the Speaker

3Dparts_instructable.jpg
PiSpeakerCircuit.jpg
PhtoFrameSpeaker.jpg
PiSpeakerLED_webapp.JPG

If you are interested in making the Instructables version of the speaker, 3D print the two STL files attached below instead of the speaker grid STL file attached in the previous step. Print the instructableLogo.STL in yellow, and in my case I also painted it with Uni Paint Pen(Fine Line PX-21), which you should be able to find at your local hardware store.

In addition, if you have your song collection online on Spotify, SoundCloud or Google Play Music you an install an mopidy extension to play songs from your collection in addition to the songs on the Pi.