YouTube is full of amazing content and just the other day I was reminded of this fact. I stumbled across some videos that are literally just hours of old 80s and 90s Christmas commercials. It suddenly gave me a great idea. What if there was a Christmas ornament you could hang on your tree and play old Christmas commercials all day long. Not only that but it could play any movie or any YouTube video. I set out to do just that.
Step 1: Watch the Video!
Step 2: Get the Parts and Tools.
Most of the parts can be found from Adafruit, with exception to the small speaker and the pocket magnifying card.
- Raspberry Pi Zero W
- 2.2" TFT LCD
- MAX98357 Class-D Mono Amp
- PowerBoost 1000 Lipo Charger
- Plastic Pocket Magnifiers
- 3D printed body on Thingiverse, or order one from Shapeways
- Plastic threading Screws
- Double Sided Tape
Step 3: 3D Print the Parts.
Take the files from thingiverse and 3D print them. My TV body warped a bit on the bottom, but my printer still needs some tuning.
Step 4: Solder on Any Needed Pins and Connections.
I added headers to the 5V and the GND on the powerboost, and I also soldered on a switch connecting the EN and GND pins. This allows you to turn off the powerboost and stop giving power to the Pi. Very handy.
Step 5: Add the Jumpers to the Components.
The Audio Amplifier Connections:
- AMP VIN to PI 3.3V
- AMP GND to PI GND
- AMP DIN to Pi GPIO21
- AMP BCLK to Pi GPIO18
- AMP LRCLK to PI GPIO19
The LCD Connections:
- LCD BACKLIGHT to PI GPIO23
- LCD SCK to PI SCK
- LCD MISO to PI MISO
- LCD MOSI to PI MOSI
- LCD CS to PI CE0
- LCD RST to PI GPIO25
- LCD DC to PI GPIO24
- LCD VIN to PI 3.3V
- LCD GND to PI GND
- PB 5V to PI 5V
- PB GND to PI GND
- Switch between GND and EN
Step 6: Setup the Pi.
Getting the Pi to use the screen was not straight forward, luckily I have figured it out for you, so if you use these steps and the exact same parts, It should work for you too.
Install Raspbian Jessie on an SD Card and update to the latest version.
You will want to enable SSH so you can talk to the Pi when its installed in the ornament.
Start with the Display:
You need to enable SPI on the pi which involves going into the config and turning it on. Enter:
navigate to "Interfaces" then "SPI" and turn it to "Yes".
Now reboot the pi.
Next you need to enable FBTFT.
You need to edit /etc/modules-load.d/fbtft.conf
sudo nano /etc/modules-load.d/fbtft.conf
now add this to the file:
Next edit /etc/modprobe.d/fbtft.conf
sudo nano /etc/modprobe.d/fbtft.conf
and add this to the file:
options fbtft_device name=adafruit22a gpio=reset:25,dc:24,led:23 rotate=270 txbuflen=32768 fps=60 speed=80000000
sace the file and reboot the pi. The screen should now be setup as /dev/fb1. You will see that in the program
Setup the Audio:
To setup the I2S simply enter this command:
curl -sS https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/i2samp.sh | bash
once its installed, reboot. Then run the same command again to test if the speaker is working!
Install the extra programs:
You will need to install a python library PyTube and a program mplayer.
To install mplayer:
sudo apt-get install mplayer
now test to see if your screen is working.
wget http://fredrik.hubbe.net/plugger/test.mpg sudo SDL_VIDEODRIVER=fbcon SDL_FBDEV=/dev/fb1 mplayer -vo sdl -framedrop test.mpg
If you see a video playing, congrats! If not, check your wiring and check the code and the FBTFT documentation.
Step 7: Test the Python Script.
First get the python script from my GitHub here. https://github.com/IdleHandsProject/tv_ornament
If you have all of the proper libraries, when you run the script it should start the server and wait for a connection from another device on the network.
To pick a video, first search youtube and find the videos URL. Example:
Now take the video identifier:
and add it to the local ip of the raspberry pi, in your browser of any device on the network. Example:
Replace the above IP with the one of your pi.
The Pi will now grab the youtube video and download it to the pi, after its done downloading it will automatically start playing. Warning some videos can take awhile to download, but once you download them once, you don't have to do it again.
Step 8: Assemble the TV Ornament
Now that everything seems to be working, its time to put it all together!
This is the time you use the plastic magnifying card mentioned before.
In the "screen" area of the 3D printed part there is a recess to bend the magnifying card and hold it in place. This will give the effect of an old CRT screen! Cut the card to approximately 60x38mm being careful not to make it too small. Keep checking fitment so that it wedges into the front to allow it to curve and stay in place.
Keep all of the jumpers connected while assembly, and be very careful of the SD card!
Next you will want to screw the screen into the housing, the pins of the screen go on the left. I only put in the two top screws, good enough.
Next install the powerboost on the right wall of the tv, making sure that the switch goes through the opening for it. The charging plug goes in the top.
Now carefully put the pi on the bottom of the tv, I used a bit of double sided tape on the bottom, but I imagine it wasn't necessary as nothing is able to move.
Finally use some double sided tape to hold on the amp to the top and place the speaker in the mess of wires, if its a metal speaker, make sure its not in contact with any components or parts on any of the circuit boards.
Step 9: Hang It on Your Tree!
Step 10: Play Some Videos!
You can play anything you want on this. Christmas movies, Christmas TV shows, the fireplace video, but my favourite is playing 90s christmas commercials. This was the reason I designed it in the first place. Something very nostalgic about them.
Step 11: Support These Projects!
If you think I have earned it, please consider subscribing to my YouTube Channel. I will be doing a lot more cool open source projects like this one in the future, and I would love for you to join along.
If you want to support me on the next level, and have some cash to spare. Please check out my Patreon. The more patrons I receive, the more complicated and intricate projects I can develop and share to the world. I want to make cool stuff, and make that cool stuff free and public for everyone else to make as well.
Runner Up in the
Raspberry Pi Contest 2017