In this Instructable I'll be showing you how to bring some analogue control to your Digital TV, by using a rotary switch to change channels on a Raspberry Pi-powered vintage TV.
The TV HAT accessory was released recently and with my love of converting old TVs (at least 6 published so far) I just had to buy one straightaway. I'll briefly cover the setup of the hardware and software, but the real test for the TV HAT was whether I'd be able to view its DVB-T stream on one of my existing TV conversions and control it with the original tuning dial.
The full video is on YouTube at https://youtu.be/LM9862GCl5o and there's a chapter link in each step. On with the setup!
Step 1: Assembly & Hardware
Assembly Video: https://youtu.be/LM9862GCl5o?t=70
Unboxing the TV HAT began with a pleasant surprise - no soldering required! This is always a bonus as it means I can dive in straightaway and not worry about frying a new accessory. I had a few minutes of confusion with the orientation of the header - it looks like a standard 40-pin connector, but if you look more closely the pin holes go all the way through the board, so you can mount it on the PI with the header facing up.
The official instructions are pretty thorough and guide you through the process step by step - my setup would have been much easier if I'd read them properly beforehand!
The TV HAT uses a new HAT form factor, and is secured to the Pi with plastic spacers and six bolts, nice and easy to put together with a small flat-head screwdriver.
Once assembled the instructions say to connect it to your TV aerial before completing the rest of the setup - I initially ignored this but it's good advice! It's possible to re-scan for channels and do the setup manually but the setup wizard is definitely the way to go.
Step 2: Software Setup
Software Setup Video: https://youtu.be/LM9862GCl5o?t=393
I found it easiest to fit the TV HAT to the Pi and set up Raspbian fully before starting the installation process. I installed all of the updates, enabled SSH and then plugged the Pi into its aerial before completing the setup via SSH on my laptop.
The setup is in two halves, firstly you need to run some scripts to set up Tvheadend on the Pi, which acts as a TV server, streaming channels to other devices on the network. It's also possible to use it with Kodi, though I've not tried that yet. As part of the setup process you select a username & password, and once the scripts have run you're all set. There was no "Done!" message when they were complete but on restarting the Pi the Tvheadend service had started automatically.
For the "TV Server" Pi i just used an old Pi 2, with an ethernet connection, and it seems well up to the task.
When the server Pi is up & running the rest of the setup is done in the browser on another computer, and the wizard starts straightaway once you've logged in. I was glad of the wizard as there are a bewildering number of tabs and settings available (that's a good thing!) in Tvheadend.
After following the instructions carefully I was presented with a long list of available TV channels and an EPG, which looks great. I didn't have much luck with Tvheadend's built-in video player but found downloading M3U playlist files really easy (click the "i") and they played well using VLC player. When downloading these it's best to save them with the channel name to make it easier to select the right one later on. Within the playlist file (if you edit it in notepad) you'll see the name of the TV show and the stream address - you can rename the TV show to the channel name if you like as the playlist is specific to the channel stream, not the programme itself.
Step 3: The 1982 TV Experience
1982 TV Experience Video: https://youtu.be/LM9862GCl5o?t=981
With the TV HAT streams playing nicely on the laptop I tore myself away from Kojak and moved to another Pi in the house - the Hitachi PI Info-TV. I built this almost a year ago and it normally just shows a stream from the Pi CCTV camera, but I now wanted it to display actual TV - after all that was it's original function! Check out the Instructable if you want to know more about how it was built.
I began by connecting a keyboard & mouse and testing the channel playlists I'd copied over from the laptop, playing them with a simple...
...in the terminal.
Some channels played OK but others had some stuttering, I resolved this by changing the Tvheadend stream settings to default to SD (standard definition) in Configuration > Stream > Preferred service video type. After this they all played fine.
The problem was likely to do with my installation of VLC, at that time (a week ago) the standard VLC player for the Pi had no hardware acceleration, so even running on a Pi 3 it was struggling a bit. Since then a new update to Raspbian has been released, with "proper" VLC included, so I can't wait to try that out and see how the performance improves.
Now I needed to add the rotary control - the Hitachi Pi already had its tuning dial connected via a rotary switch to GPIO 26 so I just needed to create a new Python script to handle the channel changing. The simple script is on GitHub and loops through a list of four channel playlists every time GPIO 26 is "pressed" The rotary switch is so tactile and works well for this, but you could equally just use a button or even a PIR sensor, change channels with a wave!
I call it the 1982 experience because it's consistent with the era of the Hitachi TV, and Channel 4 had just launched in the UK, giving us an amazing four channels to choose from! Also in those days there were very few remote controls, so it's nostalgic to use the original rotary control to select a channel as we did back then. Not sure what we did if you had a cat on your lap though.
I had a lot of fun setting up the TV HAT and bringing Digital TV to an existing Pi project - the only problem now is that the "TV Server" Pi is just sitting naked next to the Xbox in a rat's maze of cables, glowing away - I must find an appropriate vintage case for it...