Blog | About | Hire Me

Raspberry Pi TV (Part 1)

by Philippe Olivier
Created 2021-05-20

1. Introduction

In this project, we set up a system that allows us to remotely send a video file to a Raspberry Pi connected to a TV. We can then control the playback with the TV remote.

2. Hardware

This is the hardware that I ordered:

  • Raspberry Pi 4 (4GB)
  • Power supply
  • Heatsink kit
  • Case
  • Micro-HDMI to HDMI cable
  • 64GB SD card
  • Infrared sensor (TSOP58238)

3. Initial setup

3.1. First headless connection

  • Install Raspberry Pi OS with desktop.
  • In the /boot directory, create an empty file named ssh, to enable SSH.
  • Connect the RPi to an ethernet cable.
  • Connect to the RPi via SSH: ssh pi@raspberrypi.local (the default password is raspberry).

3.2. Updates and auto-updates

Make sure the system is up-to-date:

  $ sudo apt-get update
  $ sudo apt-get upgrade
  $ sudo apt-get dist-upgrade

Enable auto-updating of the RPi:

  $ sudo apt-get install unattended-upgrades

3.3. Setup SSH

First, change the hostname to rpi-tv and reboot:

  $ hostnamectl set-hostname rpi-tv
  $ sudo reboot

We can now access the RPi with ssh pi@rpi-tv.local, no matter what IP is assigned to it.

We will want to use a key file instead of a password to access the RPi. We generate SSH keys with ssh-keygen. We keep the private key on our local machine, and the public key on the RPi. Generate the key pair on the local machine (don't protect them with a password) and save them as rpi-tv and rpi-tv.pub:

  $ ssh-keygen

Now, copy the public key to the RPi:

  $ ssh-copy-id -i ~/.ssh/rpi-tv pi@rpi-tv.local

We can now log in from the local machine to the RPi with:

  $ ssh -i ~/.ssh/rpi-tv pi@rpi-tv.local

Optional: Disable SSH access with a password.

3.4. Initial config

You should disable screen blanking. There are some additional settings to take care of:

  $ sudo raspi-config

3.4.1. System Options

  • Setup wireless LAN
  • Change the default password
  • Enable desktop autologin
  • Ensure that audio goes through HDMI

3.4.2. Interface Options

  • Enable VNC

3.4.3. Localisation Options

  • Setup everything depending on your region

3.4.4. Advanced Options

  • Expand filesystem

3.5. Using VNC

On the RPi:

  $ vncserver

This will give you an IP, most likely rpi-tv:1. Use this IP to connect to the RPi from a VNC viewer, to access the GUI.

To kill the virtual desktop, on the RPi:

  $ vncserver -kill :1
This website is generated by Emacs.
Privacy