PART 2 of this tutorial will take you through the steps of building a frame for the Smart Picture Frame and Calendar and connecting a PIR motion sensor to control the picture frame slideshow transition to calendar.
Continuation of this project will use everything that was setup in DIY Smart Picture Frame & Calendar Using Raspberry Pi 3 – PART 1 of this tutorial and take you through the steps of installing OS add-ons in order to run the Python Scripts to control the PIR Sensor.
There are specific steps in every project to get from Concept to Deployment. PART 1 of this tutorial brought us through the Concept stage to the Prototype Stage and ended with Testing. In PART 2, we will make Revisions, go through Design adjustments before Getting a 2nd Prototype, which we will then Test before getting a final Deployment.
HARDWARE
OS ADD-ONS
FRAME
TOOLS
From idea to development
STEP 1 – Revisions
It’s not enough to have easy access to our Family’s online calendar. This project went a step further to integrate a slide show of family photos so as to add a nicer aesthetics to this wall mounted piece. We’ve taken the steps of putting all the content in the cloud through the use of Google Apps and overGrive. Now we need to control the switch between calendar and slideshow with a Motion Sensor so the monitor will only display the calendar when someone is standing in front of it.
STEP 2 – Design
PART 2: We’ll connect a PIR Motion Sensor to the Raspberry Pi (RPi) GPIO pins and install the necessary OS add-ons to be able to run a Python script that presses ESC when it receives input from the sensor. This way, when there is movement in front of the Smart Picture Frame, the slideshow will terminate, revealing the Family calendar in Chromium.
STEP 3 – Prototype
I. Getting Started
1) BOOT the RPi PART 1 disk image # This should load directly into Chromium Kiosk displaying your calendar
2) [Ctrl]+[Alt]+[F2] # Exit Kiosk Mode
3) >login:< with >Password:< # Get to the command prompt
4) startx # Startup Pixel GUI without Chromium
II. Install Python Script Dependencies
1) Open a Terminal window to enter commands
a) CLICK-ON the “Raspberry” icon in the upper left hand corner
b) SELECT the >Terminal< application under the >Accessories< menu
2) sudo apt-get update # Check for and install latest Raspbian Jessie updates
3) sudo apt-get install python-rpi.gpio python3-rpi.gpio # Install Python RPi.GPIO dependency
4) wget http://tjjr.fi/sw/python-uinput/releases/python-uinput-0.11.2.tar.gz # Download Python uninput module
5) tar -xzf python-uinput-0.11.2.tar.gz # Uncompress downloaded file
6) cd python python-uinput-0.11.2 # Open uncompressed folder
7) python setup.py build # Build installer
8) python setup.py install # Run installer
9) sudo nano /etc/modules # Open modules file to edit
a) uinput # add to the end of the file
b) [Ctrl]+[X] # Exit file
c) [Y] # Yes to save file
d) [Enter] # write file
10) sudo reboot # Reboot RPi for changes to take effect – follow the steps in I. Getting Started to get back to this point
11) Open a Terminal window
a) CLICK-ON “Raspberry” icon in the upper left hand corner
b) SELECT the >Terminal< application under the >Accessories< menu
12) lsmod # List active modules – confirm “uinput” has loaded
III. Connect PIR Motion Sensor
1) Using a Breadboard and Jumpers (Black, Blue, Red) connect the PIR Motion Sensor to RPi Board Pins
a) Connection Jumpers to the RPi Board GPIO pins using this color code for each pin (2)-Red, (6)-Black, (10)-Blue
b) Connect the Jumpers to the PIR Motion Sensor pins using this color code by orientation
c) Use a Breadboard to make the connection from the RPi to the PIR Motion Sensor
IV. Test
1) Create a “Smart_Cal” folder
a) CLICK-ON the “Folders” icon in the upper left hand corner
b) DOUBLE-CLICK >Documents< folder
c) [Shift]+[Ctrl]+[N] # Create new folder
d) Smart_Cal # Enter name for the newly created folder
2) Download Python scripts
a) CLICK-ON the “Blue Globe” icon in the upper left hand corner
b) GOTO Github Repository https://gist.github.com/glafranceri
c) DOWNLOAD the following files into the “Smart_Cal” folder
i. gpio_test.py
ii. uinput_test.py
iii. PIR_ESC.py
3) Open a Terminal window
a) CLICK-ON the “Raspberry” icon in the upper left hand corner
b) SELECT the >Terminal< application under the >Accessories< menu
4) sudo python /home/pi/Documents/Smart_cal/uinput_test.py # Run script – confirm following result “HELLO”
5) sudo python /home/pi/Documents/gpio_test.py # Run script – confirm following result when movement in front of PIR Motion Sensor “Motion Detected” – use [Ctrl]+[C] to exit Script
6) sudo python /home/pi/Documents/PIR_ESC.py # Run script – confirm following result when movement in front of PIR Motion Sensor “^[“ – use [Ctrl]+[C] to exit Script
7) sudo chmod 775 /home/pi/Documents/Smart_Cal/PIR_ESC.py # Make script executable
8) sudo nano ~/.config/lxsession/LXDE-pi/autostarts # Open autostart file to edit
a) @sudo python /home/pi/Documents/Smart_cal/PIR_ESC.py # add to the end of the file
b) [Ctrl]+[X] # Exit file
c) [Y] # Yes to save file
d) [Enter] # Write file
NOTE: After --kiosk add the url for your calendar without the quotations (“ “)
9) sudo reboot Reboot RPi for to test PIR_ESC.py scipt – confirm that after slide show starts moving in front of PIR Motion Sensor exits the slideshow (see video)
STEP 4 – Framing
1) Review Materials and tools list
2) Trace the outline of the monitor onto the center of the 3/4in Wood Board
3) Trace a 1/4in smaller outline inside the monitor outline
4) Use a Wood Bore to drill out the 4 corners of the smaller outline
Drilled out 4 corners
5) Use the Jig Saw to cut along the smaller outline
Cut out smaller outline
6) Confirm Monitor fits in the opening (front)
Confirm Monitor fits in the opening (back)
7) Measure and cut Natural Cork Roll oversized by 3 in to the Frame
Measure
Cut Natural Cork Roll
8) Apply a generous and even amount of glue to the side of the frame that will be covered in the Natural Cork
9) Press the Frame over the Natural Cork
Staple it to the edges of the Frame
10) Use the Utility Knife to carefully cut away the excess Natural Cork
Cross-cut and fold back the center opening
11) Confirm the Monitor fits snugly inside the center opening
It should look something like this
12) Use the 1/4in Wood Strip to line up and secure the back of the Monitor to the Frame via the VESA mount holes
13) Add a hanging point by adding two screws to the top of the Frame and winding the Picture Frame Wire between them
14) Confirm that the Monitor is supported firmly by the Frame
STEP 5 – Power Supply
1) Review the power requirements (Monitor 12V DC & RPi 5V DC)
2) Cut the USB Type-A / Micro-B cable in half and strip out and expose the wires on both pieces
3) Watch the following video to see how to map the USB wires and properly connect the Monitor and RPi to one 12V/2A Power Supply (see video)
STEP 6 – Final Assembly
1) Assemble all the components to mount in the Frame (see video)
2) Bore out the cavity for the PIR Motion Sensor
a) Select a Drill Bit that is the size of the PIR Motion Sensor cap
b) Using a scrap strip of wood to compress and protect the Natural Cork, Drill a hole through the Frame
c) Line up and trace the outline of the PIR Motion Sensor on the back of the Frame where the cap fits into the hole
d) Use the Router to cut out the traced outline down to 1/2in
e) Confirm PIR Motion Sensor fits in cavity and Jumpers reach RPi GPIO pins
NOTE: Hold PIR Motion Sensor in with non-conductive adhesive tape
STEP 8 – Deployment
1) Now that everything has been thoroughly tested and the Smart Picture Frame is fully assembled, it’s time to find a nice spot for it to go (see video)
CONCLUSION
The Smart Picture Frame is done and it’s already making it easier for my family to keep organized. Everyone can access the Google Calendar from their phones and add or edit events easily. The Picture Frame is a pleasant transition when nobody is looking at the calendar and also easy to update photos. I sure hope you are able to follow this DIY tutorial and build one for yourself.