Smart Wall Calendar

9,350

50

8

My wife and I used to have classic paper wall calendar, on
which we marked important dates. We also use Google calendar on our smart phones for marking events, so this meant double work. So I decided to build some sort of smart wall calendar, which will display our reminders, events and some other data. Since I have various old electronic parts lying around, my goal was to reuse them as many as possible and build the calendar with as little costs as possible.

In this tutorial I will show you, how to build smart wall calendar, displaying events from several Google accounts. It will also display time, date, weather, temperature and some additional information. It will be powered by a Raspberry Pi computer with a Passive Infrared Sensor (PIR) motion sensor attached to it, so that the display turns on, when motion is detected in the room, but turns off after few minutes of inactivity. This tutorial is based on several other tutorials I found on the internet and I will give the links to them for better understanding. Some basic programming knowledge is needed (HTML, Python, …).

Step 1: The Hardware

As mentioned before, I tried to reuse as many old electronic
parts to keep the costs down. However some items I had to buy, so I will list all that is necessary for the construction.

- A Raspberry Pi kit. Initially I used my old model 2 from some other project. It worked, but the web page editing and reloading took me a lot of time, so I eventually swapped to model 3, which works more fluently https://www.ebay.com/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=raspberry+pi+kit&_sacat=0

- LCD screen. I used the screen from my old laptop, so I only needed to buy LVDS driver board for it and the power supply https://www.ebay.com/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=hdmi+driver+LVDS+board&_sacat=0

- Plastic storage box for the electronics https://www.ebay.com/itm/Plastic-Storage-Box-Jewelry-Craft-Nail-Arts-Beads-Container-Organizer-Case-Tool-/163084011577?hash=item25f8908839

- Passive infrared motion sensor https://www.ebay.com/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=PIR+motion+sensor&_sacat=0

- AM2302 temperature/humidity sensor https://www.ebay.com/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=AM2302+&_sacat=0

- Black plastic slide-on binder for LCD frame https://www.ebay.com/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=plastic+slide+binder&_sacat=0

- Various cables (HDMI, 5.5mm for DC power, solderless breadboard jumper cables, …)

Step 2: Creating the LCD Display

I used the LCD screen from my old obsolete laptop. There are
several tutorials on how to do this, I followed this one:

https://www.instructables.com/id/How-to-reuse-the-old-LCD-Screen-of-your-broken-Lap/

I dismantled the cover of my old laptop, took out the LCD display and then ordered the correct LVDS driver board. I provided the seller the product code, which could be found on the back side of the LCD, in my case it is LP171WE3 (TL)(A2) - see bottom right label on last picture, and then he sent me the appropriate LVDS. Please note, you’ll also need the power supply for the display, so ask the seller to send it too. I also purchased a nice 14.5×7.5×2cm plastic box to fit the driver board nicely and attach it to the back side of the LCD.

Now the LCD display has metallic frame, which doesn’t look pretty. Initially I spray painted it to black, but the paint started to peel off. So I took four black plastic slide-on binders, which are typically used for binding sheets of paper, trimmed them accordingly and attached them to cover the frame. This looked well, so I connected all the cables, plugged in HDMI to my old Raspberry Pi and Voila – it worked! There was a picture showing on the display, so I was ready to move on the next step – what information to show on the display and how to show it.

Step 3: Setting Up the Software

When I was looking over the internet for some clues, how to build calendar, I was inspired by this page https://dakboard.com/site. They provide the finished product (the display, computer and working software), but they also have an excellent tutorial for DIY solution (https://blog.dakboard.com/diy-wall-display/). I recommend you to follow this tutorial, at least for the first part with the instructions on preparing and setting up the system on Raspberry, so that the browser auto-loads the desired web page on boot.

This worked nicely, however I was looking for some solution, which could be more customized according to my wishes. I’ve decided to set up my own web server and create a web page, which will show additional information besides the calendar. I’ve chosen Wordpress.org, since it’s well documented and has good support and large community to help you. Here’s the tutorial on how to install Wordpress on Raspberry Pi: https://projects.raspberrypi.org/en/projects/lamp-web-server-with-wordpress. With Wordpress installed, it was time to design my homepage. You can use one of the many provided themes, or design from scratch. Anyway, some HTML programming knowledge is be needed for this.

I’ve designed my page, so that on the left side the calendar is shown (https://sl.wordpress.org/plugins/google-calendar-events/), while on the right side time and date are shown (https://www.timeanddate.com/clocks/free.html and https://www.arclab.com/en/kb/htmlcss/display-date-time-javascript-php-ssi.html). Weather forecast is from this page (http://www.1a-vreme.si/vremensko-okno/), which provides forecast widget for Slovenian cities, but I guess widgets for other countries could be found as well on the internet. Temperature is collected using AM2302 sensor (https://www.ebay.com/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=AM2302+&_sacat=0), as explained at the end of this chapter. On the bottom is a simple daily countdown timer, which displays how many days left to some event (interesting for my children to know, how many days will they have to wait for something). In the top right edge is the MetaSlider plugin (https://wordpress.org/plugins/ml-slider/), which randomly slides to selected pictures of my family. Additionally I’ve used Background Slider plugin (https://sl.wordpress.org/plugins/background-slider-master/) to show me some random picture for nicer background.

As mentioned before, the indoor temperature is collected using AM2302 sensor. There are many tutorials on how to get temperature, I followed this one: https://www.modmypi.com/blog/am2302-temphumidity-sensor. Later I moved this sensor to another Raspberry Pi with Home Assistant running on it, because it is easier to read and publish values using its DHT Sensor component (https://www.home-assistant.io/components/sensor.dht/). Home Assistant can also collect outside temperature using various weather components, I used YR.no component (https://www.home-assistant.io/components/sensor.yr/). With that, I wrote an automation script to gather indoor/outside temperature from these components and write them to a text file, which is then displayed on my wall calendar. For more information on Home Assistant, see the homepage (https://www.home-assistant.io/).

Step 4: Optional - Turning Off the Display

Now we have our calendar set up and running, just the way we like it. But we don’t want the display to be turned on 24/7. We only want it to on, when someone is home. Also we don’t want it to be turned on in the middle of the night, when we go to the toilet, it’s too bright! So we’ll attach an infrared sensor to notice, when somebody is standing in front of it, and add some time limits, when it should turn on.

Please note that my programming skills are rather limited, so the following could not be optimal, since I’ve picked it from various online forums and tutorials, but essentially it works. Still, any recommendation is still welcomed. First we’ll start with test to turn monitor on/off manually. For that, we’ll create two files (for example monitor_on.sh and monitor_off.sh) and write some code in it. The easiest way to do this is to log into your Raspberry using SSH and type

sudo nano monitor_on.sh

and type the following code

tvservice --preferred;

startx /usr/bin/graphical_launcher `fgconsole`

Press CTRL+X to save and exit, then create the second file

sudo nano monitor_off.sh

and type the following code

tvservice --off;

Again, press CTRL+X to save and exit. Make these newly created files executable:

sudo chmod +x monitor_on.sh

sudo chmod +x monitor_off.sh

Now to try if these commands are working, type

sudo ./monitor_off.sh

sudo ./monitor_on.sh

The monitor should now turn off and on accordingly. I’ve noticed that on Raspberry Pi 2 it took almost 10 seconds for the monitor to turn on. On Raspberry Pi 3 it takes 1-2 seconds. Next we will connect an infrared sensor, which will trigger these scripts. Again, there are many tutorials how to set up Raspberry Pi and PIR, I followed this one: https://www.instructables.com/id/PIR-Sensor-Interfacing-With-Raspberry-Pi/. Basically, create a file with using nano editor (for example motion_sensor.py) and type the appropriate Python code in it. Below is the example of my file:

import RPi.GPIO as GPIO
import time
import sys
import subprocess
import datetime as dt
import os
GPIO.setwarnings(False)
# GPIO.setmode(GPIO.BOARD)
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN) #PIR
turned_off = False
last_motion_time = time.time()
SHUTOFF_DELAY = 180 # seconds
while True:
i=GPIO.input(17)
if i==0: #When output from motion sensor is LOW, turn monitor OFF
if not turned_off and time.time() > (last_motion_time + SHUTOFF_DELAY):
print "No intruders",i
turned_off = True
time.sleep(1)
subprocess.call(['/home/pi/monitor_off.sh'], shell=True)
elif i==1: #When output from motion sensor is HIGH, turn monitor ON
print "Intruder detected",i
time.sleep(1)
last_motion_time = time.time()
sys.stdout.flush()
if turned_off and dt.datetime.now().hour > 5 and dt.datetime.now().hour < 23:
turned_off = False
subprocess.call(['/home/pi/monitor_on.sh'], shell=True)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
GPIO.cleanup()

Note that “GPIO.setup(17, GPIO.IN) “ indicates that output pin from PIR is connected to pin 17 on Raspberry Pi. Which pin is that depends whether you define GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM). The difference is explained here: https://raspberrypi.stackexchange.com/questions/12966/what-is-the-difference-between-board-and-bcm-for-gpio-pin-numbering. I have # in front of GPIO.BOARD, so it’s ignored and GPIO.BCM is used.

Notice the line

SHUTOFF_DELAY = 180  #seconds

Here is stated, how long the monitor is turned on since last motion was detected, before it is turned off. This is useful because I don’t want the monitor to turn off/on constantly when I walk by it, but want to keep it turn on for some time, before it’s off. I’ve chosen the interval of 180 seconds, so that the monitor turns off about 3 minutes after the last motion was detected.

Finally, this line

if turned_off and dt.datetime.now().hour > 6 and dt.datetime.now().hour < 23:

states that the monitor only turns on between 6:00 and 23:00, so it doesn’t disturb me during night time. The lines

print "No intruders",i

and

print "Intruder detected",i

are for testing the script only, you can delete them later, when you’ll have it working. Now test the script:

sudo python motion_sensor.py

You should see messages “Intruder detected”, if you wave above the sensor, otherwise it will be “No intruders”. When this script is tested and is working, set it to start at boot:

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

and add the following line

@sudo /usr/bin/python /home/pi/motion_sensor.py

Of course you must specify the correct file name of the Python script you created.

Step 5: Hang the Calendar

With all set up, it’s time to hang the calendar on the wall!

Initially I was thinking of hiding Raspberry Pi behind the LCD display, so that only one cable (DC power) would be needed. But since Raspberry runs on 5V and LCD display runs on 12V, I would need additional transformer. Also, the Raspberry case is rather thick, which means the LCD would be spaced about 3 centimeters from the wall. So I abandoned this and only left LCD electronics behind the LCD, so that it is now less than 1 centimeter away from the wall. I acquired two 5 meter long cables, one HDMI and one 5,5mm for DC power supply. Both cables are white, like the wall, which means they don’t stand out much. I’ve fitted the LCD on the wall and put Raspberry on top of refrigerator on the opposite wall, so it’s basically hidden, yet still easily accessible.

Share

    Recommendations

    • Trash to Treasure

      Trash to Treasure
    • Tape Contest

      Tape Contest
    • Arduino Contest 2019

      Arduino Contest 2019

    8 Discussions

    0
    None
    WolfgangB20

    5 months ago

    Thx for this, but i got a problem with the motion sensor. when i try to test the script i am getting this message, Maybe you can help with that thx.

    pi@raspberrypi:~ $ sudo python motion_sensor.py
    File "motion_sensor.py", line 30
    if not turned_off and time.time() > (last_motion_time + SHUTOFF_DELAY):
    ^
    IndentationError: expected an indented block

    2 replies
    0
    None
    sgalufWolfgangB20

    Reply 5 months ago

    Indentation is very important in Python. It defines the scope of bolck, that is intended to be inside a loop or something else. For more information see this course:
    https://www.python-course.eu/python3_blocks.php
    Unfortunately when I pasted the Python script into the instructable, the indents were lost, so I guess in your script the block of lines, following the"if" state, isn't indented, but it should be.

    0
    None
    WolfgangB20sgaluf

    Reply 5 months ago

    Thx a lot. I will try that out. Sorry about the question, i don't know anything about python, but this site helps to understand what it means.

    0
    None
    DynamoBen

    7 months ago

    I believe sudo chmod +X should be sudo chmod +x, the lowercase x makes the file executable.

    1 reply
    0
    None
    sgalufDynamoBen

    Reply 7 months ago

    you are correct, I'll fix it

    0
    None
    Philip J.M

    7 months ago

    I've considered switching from Dakboard to website and just build my own screen but then I got thinking about privacy. If the website is out there you are basically exposing your family's Todo list (aka, when is everyone out of the house) as well as images to anyone who is bored and lands on it. What's your take on that?

    1 reply
    0
    None
    sgalufPhilip J.M

    Reply 7 months ago

    The website is hosted on the Raspberry, which is behind my router with no ports forwarded, so I guess it's accessible only from within my network.

    0
    None
    Penolopy Bulnick

    7 months ago

    A smart calendar seems really handy :D