Bugs, Bolts, and Wires - Cybersecurity, DIY Projects, and Electronics!

Turning an old monitor into a Calendar

Turning an old monitor into a Calendar
Raspberry Pi 3 PIR

For my final project in my Intro to Operating Systems class, I was tasked with making a PowerPoint detailing a project involving an OS.  I choose to show how to use a Raspberry Pi to turn a spare monitor into a digital calendar that would only turn on when someone was in the room and then would turn off when they left.

I had never used a Raspberry Pi before and wanted an excuse to buy one, so I took this opportunity to purchase one and learn how they work and what they could do.

At this point I was pretty familiar with Linux, I have been using Linux off and on for about 12 years now.  However, I wouldn’t say I’m an expert or a superuser, but instead, my experience level would probably put me at an amateur level.

Materials, Cost, and Time


Material Quantity Cost
Monitor 1 Free (old and damaged)
Raspberry Pi Kit

Includes: HDMI, power cable, case, 2 heat sinks, 8GB micro sd card, Raspberry Pi 3 B, Preinstalled OS.

1 $56.99
Mouse & Keyboard 1 Free (old)
Jumper wires 3 40pcs @ $6.99
PIR motion sensor 1 5pcs @ $9.99
Total Cost $73.97

The estimated time to complete this project is about 8 hours for a beginner.  This accounts for troubleshooting and frustration breaks.

Project Guide

This tutorial will walk a beginner through the steps needed to turn an old monitor into a digital calendar, using a Raspberry Pi.  At startup, the Pi will open up a web browser in kiosk mode and display your google calendar.  However, it doesn’t stop there, the monitor will be controlled by a motion sensor to turn the monitor on or off, based on if someone’s in the room.

Setting up the Pi

First things first, take the Pi out of its packaging and read the directions that come with it.  Then place the Pi in the case, screw it in place, and plug in the Micro SD card.  Lastly, plug in the monitor, keyboard, mouse and finally, the power cable.  The Pi should start up and be ready to go.

Setting up the OS

Some settings need to be changed once the Pi has loaded up to the GUI.  Use the menu to open up preferences and then configuration.  From here change the Password, Hostname (so you’ll recognize it on your network) and expand the Filesystem to use the whole SD card.  Also, make sure to turn on Boot to desktop.  Under Localisation tab, set up the locale, timezone, keyboard and WiFi country.

Before moving on, open up the WiFi menu and connect to your network.  The menu is at the top right of the desktop.

Updating the Pi

The next task is to make sure the Pi’s OS, Rasbian, (an optimized Debian Linux distribution) is up to date.  To do this open up a terminal by pressing ctrl+alt+t.  In the terminal type:  sudo apt-get update  (this updates the list of essential files and programs to the newest versions). Then run:  sudo apt-get dist-upgrade (this upgrades all essential files and programs to match the list that was updated).

Turning off Power Save Mode

Now, let’s prevent the Pi from going into power saver mode.  Open up another terminal and type: nano /etc/lightdm/lightdm.conf (nano is a terminal text editor and lightdm.conf is a text file that controls settings for the GUI and greeting screen).  To prevent the Pi from going into sleep mode, edit the line under the:

#xserver-command=X    to    #xserver-command=X -s 0 -dpms
Press ctrl-o, type y to save, and press ctrl-x to exit.

Programs needed

The default browser that comes with the Pi, is not the greatest so let’s download and use Chromium (an open source version of Chrome).  To install use the terminal and type:

sudo apt-get install chromium-browser

Next, install unclutter to hide the mouse cursor when not in use. Type:

sudo apt-get install unclutter

Display Calendar at Start-up

First,  open up Chromium and log into your google calendar and tell the browser to remember you and your password on this device.  Then go to settings and under On Startup, click open specific page, click set pages, and add: https://calendar.google.com/calendar/render?pli=1#main_7%7Cmonth. Press ok.

 Next, start up a terminal and type:

nano ~/.config/lxsession/LXDE-pi/autostart

Add the line:

@ chromium-browser --noerrdialogs --disable-session-crashed-bubble --disable-infobars --kiosk

Press ctrl-o, ctrl-x to save.

Connecting Infrared Sensor

The PIR (Passive Infrared Sensor) has 3 pins. VCC (5v in), GND (ground), and Out (3.3v out).  The Pi has 40 pins.  8 GND, 2 5v, 2 3.3v, 2 advanced, and 26 GPIO (General Purpose Input/Output) pins.  Connect the PIR GND to any GND pin, the VCC to one of the two 5v pins and then the Out to any GPIO pin (remember the GPIO pin number).

PIR Pin Layout


Raspberry Pi 3 B


Raspberry Pi 3 B with PIR connected


Sensor Script

To get the sensor to actually do something we need a script.  We actually need 3 scripts.  All saved in the folder called /home/pi/Documents/PIR.


#!/usr/bin/env python
import sys
import time
import RPi.GPIO as io
import subprocess
SHUTOFF_DELAY = 10  # seconds
PIR_PIN = 21         # Pin 40 on the board
def main():
    io.setup(PIR_PIN, io.IN)
    turned_off = False
    last_motion_time = time.time()
    while True:
        if io.input(PIR_PIN):
            last_motion_time = time.time()
      if turned_off:
        turned_off = False
            if not turned_off and time.time() > (last_motion_time + SHUTOFF_DELAY):
        turned_off = True
def turn_on():
    subprocess.call("sh /home/pi/Documents/PIR/monitor_on.sh", shell=True)
def turn_off():
    subprocess.call("sh /home/pi/Documents/PIR/monitor_off.sh", shell=True)

if __name__ == '__main__':
  except KeyboardInterrupt:

We now need two more scripts to run. These scripts will control turning on and off the screen based on motion. We’ll be using nano again to create these files.



tvservice -p && sudo chvt 9 && sudo chvt 7



tvservice -o

All three scripts need to be changed to executable by using the terminal, navigate to the folder location and typing chmod +x scriptname.


The  tvservice controls the HDMI output feed to a screen

The -o turns off the feed and the -p turns it on.  Unfortunately, this messes up the video buffer, so when you turn on the screen it won’t display unless you reset the buffer.  The best way that I found is to sudo chvt 9 and back to chvt 7 (chvt creates a virtual terminal) this will change the screen and has the effect of changing a channel like on a tv.  This happens to reset the buffer and allows you to see the screen again.

Final Touches

The last thing we need to do is go back to lxsession and add the script to start up on system start.

nano ~/.config/lxsession/LXDE-pi/autostart

Add the line to the bottom of the file.

@sudo /usr/bin/python /home/pi/Documents/PIR/monitor_PIR.py

At this point, everything should be good to go. Just restart the Raspberry Pi and on startup give it a min to load everything.  Good Luck!

Leave a reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>