This iconic 1970s digital clock now has a new life displaying YouTube statistics, thanks to a funky Pimoroni "Inky pHAT" E Ink display and a Raspberry Pi Zero. It uses a simple Python script to query the YouTube API on a regular basis, refreshing the display with the data it retrieves, displaying the very latest site stats.
The original Alarm On/Off switch at the rear toggles the display between Subscribers and Views for a specific YouTube site (in this case mine!).
The clock itself is a Digitron model, quite an early LED clock for the consumer market, solidly and stylishly cased in a sturdy aluminium body.
Back in Time for UpcyclingI picked up this clock at a sale a few years back and until recently it was in daily use, tucked underneath the TV unit and keeping great time. Recently though we came into the room to find the LED display flashing crazily, with a disturbing buzzing sound, and it was obviously time for it to retire to the workshop.
I'd first been attracted to it by its solid construction and style - it's pretty much a solid lump of aluminium and very heavy. I loved the aesthetic so much I decided to rebuild the now-broken clock into an understated IoT device to provide passive information in my office.
The dismantling gave me a big clue to its bulk - modern LED clocks will often have a "wall wart" adaptor and run on low voltage, but this monster took full mains voltage and had a large transformer within the clock itself - accounting for its weight!
Aside from the bolts holding the stand in place the rest of the components were fixed to either the rear or front panels, which were made of plastic. I discarded the transformer, circuit and old LED display, and was left with a solid shell, front and back panels and some switches, which I boxed up waiting for the right idea to come along.
Channel BuildingAbout a year ago I started "Old Tech. New Spec." on YouTube - a dedicated channel for my project videos with a consistent format and design. I'd started to enjoy making project videos almost as much as the projects themselves and this felt like the logical next step. There was also no shortage of footage, as I routinely video things like tear-downs so I can look back later on and see how things are meant to fit back together.
I've not released that many videos yet but learn something new from each one. The video for the recent "PiNG Video Doorbell" was the most fun so far but was way too long - so I decided the next project would be a simple and minimalist YouTube stats counter, to sit on my desk and help keep me motivated. Now I just had to figure out how to get the numbers from YouTube onto the Pi - how hard could it be?
Seizing the StatsI started my research by following a guide in the MagPi magazine, which retrieved follower stats from a bunch of different social APIs (Application Programming Interfaces), stored the numbers in a MySQL database then displayed them on an LED display. This worked well but seemed like overkill for this project, so I looked for a simpler solution, having still learned some valuable lessons about how APIs work.
I soon discovered the Requests module for Python, and after looking through some extremely helpful examples realised I could easily query the YouTube API and return some basic statistics for my channel.
If you want to do something similar the first step is to log into the Google Console and create a new Project - from there you can link the YouTube API to your project and retrieve the credentials you need (Channel ID and API Key) to pull out the statistics using Python. I followed Google's really useful guide to set up the project and get the API key, and followed these steps to retrieve the Channel ID.
The Python code I used is documented on Github - it's commented and pretty straightforward to use for yourself as long as you paste in your own credentials. It only uses the Requests module, which is already installed by default on Raspbian, so aside from the display there's nothing else to install, unless you want to use a specific font. You're definitely not limited to YouTube though, the Requests module is very flexible and can help you retrieve data from thousands of sources, one example would be a daily step counter, connecting to a fitness API.
Once I was happy with it I set the Python script to start automatically on bootup by editing the autostart file:
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
...and adding in the following line to the bottom:
@python3 /home/pi/YTcounter.py
Now that I was able to retrieve the numbers I wanted from YouTube the next step was to display them - in a way that would fit the retro-style of the clock.
The Inky OptionI considered several different display options for this project but settled on the Pimoroni Inky pHAT - a small three-colour E Ink display for the Pi. I picked one up over the winter after scooping a voucher in last year's Yarr Booty challenge but never got round to using it, so this seemed like the ideal opportunity. Plus, most importantly, the display was a lovely shade of red, nicely matching the front panel of the original clock.
The software for the Inky pHAT was easily installed following the setup instructions and in no time I'd run one of the examples on my Test Pi to make a cool name badge. After some more experimenting I was able to display basic text using a specific typeface (matching the one I use in my YouTube branding), and from there it was straightforward to display the output of the API request - the comments in the Github code show how this is coded step by step.
The Inky is designed to fit on top of the Pi's 40-pin GPIO header but I wanted it to fix it to the "screen" so decided to connect it to the Pi via male-to-female jumper cables instead - this made its placement more flexible and left some GPIO pins spare to connect an LED and switch (more on those later). I followed the diagram on pinout.xyz, noted that 8 GPIO pins were required, plugged the cables in, tested it and - nothing! I hadn't realised that although only 8 GPIO pins were required the pHAT also needed to be connected to multiple GND pins. Once these were all connected with jumpers (a fiddly business) the Inky once again worked as planned, big relief.
With the code working I now faced the usual challenge - fitting all of the parts into the case.
Lego, Chopping and GlueFitting the Pi Zero into the case was first, and for this I fell back on my favourite construction material, Lego. It's just perfect for fitting components together, and crucially allows for easy dismantling as well as assembly. After drilling some holes in Lego base plates I fixed one to the Pi board and one to the clock body with its original stand bolts, so they would clip together and hold the Pi in just the right position.
Next was the "face" - the original red perspex at the front of the clock was too opaque for the Inky display to show effectively so I had to cut out a section for it to peep through. This was undoubtedly the hardest part of the build, as the hole had to be cut very accurately and if I screwed it up there was no hope of a replacement, save having a bespoke one laser-cut (which I researched just in case!). With the help of a cheap vernier caliper (my new favourite tool) I was able to measure and score the outline of the hole precisely, which I then cut out roughly with a rotary tool and tidied up with a small file. This was slow going and took a whole evening but was worth it!
The Inky pHAT was then hot-glued as neatly as possible to the red perspex, ready for assembly.
Final Touches and AssemblyWhen experimenting with the responses from the YouTube API I found I could return two separate "interesting" numbers - Subscribers and Total Views. With the Inky pHAT it would've been possible to display both at once but I really liked the clock-like cleanliness of just a single large (font size not amount!) number. With some tweaks to the code I was able to wire up the clock's original "Alarm On/Off" switch to the GPIO, so that the display could be toggled between Subscribers and Views - this was a satisfying touch, especially as the Views number changes much more often than the Subscriber count!
Next I added in a bright white LED to the GPIO, coding it to light up just before the API request was sent and turn off afterwards. I'd already scraped all of the paint from the rear of the translucent red plastic, so the idea was that the clock would glow red a bit while the numbers were being refreshed.
With all of the GPIO connections made in advance and the power cable connected the assembly went really well, largely thanks to the Lego holding things in place. The front and back panels were a tight friction fit, but clipped together in the end - I just hope I don't have to dismantle it any time soon. The moment of truth was the first turn-on after assembly, with the jumper cables snaking around inside the case and the GPIO connections so tightly squeezed I had no great hopes, but was delighted when the display refreshed after what seemed like an hour-long boot process.
Motivational FiguresI love how this project turned out, it's certainly one of the "cleanest" I've ever built, thanks to the beautiful solid-aluminium design of the original clock. It's been a great learning experience too, I've picked up a lot about working with APIs and E Ink that I know I'll use in future projects.
What I love most is the simplicity and practicality, it has one job, does it well and looks good while doing it. I didn't tend to keep an eye on the YouTube stats before, but this has brought raw online data into my office, presented in an attractive and non-intrusive way. I may never build the audience for Old Tech. New Spec. to the dizzying heights of Marty's Matchbox Makeovers or The Hydraulic Press Channel, but as long as it's fun I'll keep making projects and videos to hopefully inspire more people to up-cycle their old devices into something fresh and useful.
The kids & I are fascinated to see the view count change, however slightly, it lets us know that somewhere in the world someone has just viewed a project video, and that definitely spurs us on to keep creating and sharing.
If you liked this project please check out my other projects for more old tech upcycling, and subscribe to the YouTube channel for regular video content.
Comments