Raspberry PI web tvservice

What is it? questionmark

Having some spare monitor’s laying around (from the dumpster), I did already make some nice projects with them. In the Dual photo webpage with Angular project I added some nice tvservice magic.
I thought it was worth having its own place.

This project is nothing more than a webpage (not even a page, more a web command listener) to turn the connected HDMI monitor on and off.

Turning the monitor on and off

With the use of the tvservice command, we can just remove the HDMI signal. The monitor will then go to sleep, waiting for the HDMI signal to come back on.

Easy commandline HDMI tests
This monitor shows a breef (2 second) message that it will go to sleep after the HDMI signal has been lost

The code

All the code can be found on my github: https://github.com/timdows/RaspberrypiWebTvservice

It creates three get endpoints:

  • display-off
  • display-on
  • dispaly-on-timer

Every endpoint makes sure the display goes ON/OFF or ON on a timer.
By default, the express server listens on port 3000.

Configure express server to host the webpage

I picked express server for nodejs to host the webpage.

If you are running on a ARMv6 environment (Raspberry Pi Zero W), you will needed some custom installation instructions to get node and npm installed. Luckily there is an easy installation https://github.com/sdesalas/node-pi-zero.

To use the application execute the following commands:

git clone https://github.com/timdows/RaspberrypiWebTvservice
cd RaspberrypiWebTvservice
npm install

It is then as easy as running it:

node server.js

Startup on boot

I use pm2 for this. The executable script looks like this:

cd ~/RaspberrypiWebTvservice
node server.js