UPDATE April 22, 2019:
Formerly, the Deco Clock used weather information from Weather Underground. Weather Underground has stopped their feed. The clock still works, but no weather is being retrieved.
See the posting at: End of Service for the Weather Underground API.
The script deco_clock_weather.py has been changed to use the Dark Sky API to get weather conditions. This will require you to obtain an API key by registering at DarkSky.
InspirationResearch for my previous project on hackster, the miniz streaming radio, introduced me to the beautiful world of Art Deco clocks. While building the deco-inspired miniz, I added a deco clock face as an option. I also wanted to add a weather feed as a separate screen. Unfortunately, I couldn't add weather - that used too much memory on the raspberry pi zero W.
After the miniz was complete, I kept thinking of the impressive clocks, especially one by Gilbert Rohde for Herman Miller. Would be nice to build a clock taking design cues from that Rohde clock. Hmn. A clock is light-weight, memory-wise. Maybe fit a weather display in there, too?
Yes! Let's build it....
Skill LevelEasy. The basic build is fairly straightforward. There's 3D printing, but no printer, no worries - you can outsource that. Download and configure software. Assembly: just mount a raspberry pi Zero WH on an Adafruit piTFT, and screw that into the case. With a Raspberry Pi Zero WH - no soldering required!
For the adventurous, I'm including optional, advanced post-print treatments. This discusses my experience with vinyl car wrap on 3D parts. Make no mistake - these options are challenging.
CostFor the basic build, around $60 USD, not counting the 3D print and depending on what you already have on hand. Most of the cost is for the Adafruit piTFT plus 3.5 inch 480x320 LCD. For a clear, detailed display, you need that resolution.
Build TimeAbout 2 hours, not counting 3D print time. 3D print about 5.5 hours for the case and about 1 hour total for a front bezel and two side decorative pieces. Software download, install and configuration will take maybe 1 hour 45 minutes to get the default clock running. Weather configuration will take more time. Mounting into the case, about 15 minutes.
OverviewI'm re-using/re-purposing some of what I learned in the miniz project. Yay!
- A Python program uses the great pi3d graphical software to emulate a clock and display current weather conditions for your location
- Your choice: run a clock (two different styles available), weather conditions with time, or BOTH in rotation - easily set with software variables
- The clock uses time from the standard raspi-config localization - set and forget
- Pulls weather conditions from wunderground via xml, if location is available, or API; this mayfail in the future
- You'll have to supply location information if you want to display weather
- Not all locations around the world will work. But wunderground can provide weather for thousands of locations. I’ll show you how to test if you can get weather for your area.
The clock routine grabs local time and feeds to pi3d to make the clock hands move on the screen. Likewise, pi3d presents an Art Deco-looking background that displays a graphical icon for the most common weather conditions (sunny, rain, etc.), time, temperature, and a word description of conditions. The weather comes from a wunderground xml feed split out by the python package feedparser.
As first installed, only the clock will display. If you want to see weather for your location, you'll have to adjust some variables.
BuildStep 1: Raspbian Stretch Lite
- Download Debian Stretch Lite
- Install to micro sd card. This is a good set of instructions.
- Two files need to be added to the /boot directory on the new sd image card.
On Windows, create an empty file called ssh and a file named wpa_supplicant.conf with the contents shown (second box) below
For Linux/Mac:
sudo touch ssh
sudo nano wpa_supplicant.conf
And for Windows/Linux/Mac, enter and save the following, changing ssid and psk to your router's ssid and password:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
ssid="Your network SSID"
psk="Your WPA/WPA2 security key"
key_mgmt=WPA-PSK
}
After getting Raspbian start-up configured, run headless (no monitor/keyboard/mouse) - insert the SD card into your pi and power up. Allow a few minutes for the pi to fully start up. If you are running Windows, download the putty terminal emulator to connect to the pi with SSH. You should be able to find the IP address for the pi from your router's web page. And, to SSH in from a Mac/Linux terminal:
ssh "192.168.0.xxx" -l pi
Where "192.168.0.xxx" = your pi's IP address (without quotes). The default password is raspberry. Be sure to change it on first login, via:
sudo raspi-config
- Network Options/Hostname (I named my host DecoClock)
- Localisation Options, especially for local time
- Advanced Options - Expand Filesystem and Memory Split
- For Memory Split, change the value to 128 (needed for pi3d, later)
After completing the config, reboot. When you sign back in, update packages and set up git:
sudo apt-get update
sudo apt-get upgrade # This step takes a long time!
sudo apt-get install git-core
git clone http://github.com/thisoldgeek/DecoClock
Cloning this github repository will create a new directory under /home/pi/DecoClock. This DecoClock directory contains all the assets needed for this project, including setup scripts and documents.
Step 2: piTFT
Shutdown your clock for mounting onto the piTFT. Insert the pi zero headers into the piTFT and reboot.
Setup the 3.5 inch piTFT for OpenGL using the Adafruit tutorial. Although this is written for Raspbian Jessie, it works for Stretch.
cd ~
curl -O https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/pitft-fbcp.sh
sudo bash pitft-fbcp.sh
When the pitft-fbcp.sh starts, choose "6. Configure options manually", and input the following values at the prompts:
Do the piTFT 3.5 inch setup using the manual config operation, with HDMI Rotation option 1Normal and TFT(MADCTL) rotation 2, 90 degrees. This will allow the pi zero, when attached to the piTFT, to have its power connector at the lower right, when the face is viewed from the front.
When the script finishes, it will ask you if you want to reboot. For now, enter 'N' and continue configuration.
To suppress text messages on the screen before the decoclock service starts, do:
sudo nano /boot/cmdline.txt
And add:
quiet splash loglevel=0 logo.nologo
To the end of the existing text. Also change:
console=tty1
To:
console=tty3
Now,
you can reboot by:
sudo reboot
Step 3: Setup Python Libraries
Run this to setup all the libraries:
cd ~/DecoClock/scripts
chmod +x py_libs_install.sh
./py_libs_install.sh
This is what the script is doing - a lot! Will take awhile.
#!/bin/sh
# run installs with sudo!
echo ***Running update and upgrade***
sudo apt-get update
sudo apt-get upgrade
echo ***Installing python3 pip***
sudo apt-get install python3-pip
echo ***Installing pi3d***
sudo pip3 install pi3d
echo ***Installing python3 PIL Required for pi3d***
sudo apt-get install python3-pil
echo ***Installing python3 numpy Required for pi3d***
sudo apt-get install python3-numpy
echo ***Installing feedparser***
sudo pip3 install feedparser
echo ***Installing WiringPi for gpio control, to dim backlight***
sudo sudo apt-get install wiringpi
Step 4: Set User Options
There are several variables you can use to customize the Deco Clock. You can adjust these before running decoclock.sh, below:
- Clock style: white or green
- Clock only, weather only, or both on rotation
- Rotation display interval, default 30 seconds
- API Key for DarkSky
- lat/lng: Latitude and Longitude for your location
- Style for weather icons: flat or "deco"
- 12 or 24 hour clock on weather display
- Fahrenheit/Centigrade display on weather
- Dimming the screen brightness at night
To see what graphics options are available by changing the variables, please see DecoClock/docs. This contains images of the clocks and weather icons.
Change these variables in ~/DecoClock/deco_clock_weather.py. The values shown are the supplied defaults or user-specific values:
# API Weather Variables - change for your Key and location
api_key = "*****************************" # Dark Sky API Key
#- Go to https://darksky.net/dev/ and sign up for a free API key
# Use http://www.latlong.net to get YOUR lat/lng values (required for API)
lat = 37.961461 # change me
lng = -122.087975 # change me
time24 = False # If True, uses 24 hour weather display, else 12 hour display; does NOT affect clock face, only weather
clock_style = 2 # clock_style: 1 = white, 2 = green
wi_style = 2 # wi_style (weather icon style); 1 = plain/flat, 2 = art deco style
screen_num = 1 # 1 = Clock, 2 = Weather
rotate_display = False # False: Show one screen only, either clock or weather based on screen_num; True: rotate screens every display_interval
display_interval = 30 # Switch between clock and weather every 'n' seconds
centigrade = False # centigrade = True, use degrees C; False, Fahrenheit
Additional info:
Default behavior at first install is to show a clock, no weather. If you want to show the clock and weather on rotation:
- Change rotate_display to True
- You can also show ONLY the weather by screen_num = 2, rotate_display = False, and supplying LOCATION and API Key for DarkSky.
When you are satisfied with your changes, run the following to install the decoclock service that will run at boot:
cd ~/DecoClock/scripts
chmod +x decoclock.sh
sudo ./decoclock.sh
cd ~/DecoClock
chmod +x deco_clock_weather.py
sudo systemctl restart decoclock
Step5: Build the Case
My 3D printer is the small/slow/cheap Monoprice Mini Select V2. I have a glass bed installed, but I also use AquaNet Hair Spray for hold-down. Your settings/process may vary.
For color choices, suit yourself. I used BamTak Purple and Yellow-Gold, which is a color combination used in Deco Art.
Print the case and bezel face down on the bed, skirt only. Print the rods flat on the bed,
I printed each of the components - bezel, two rods - separately. On the MP Select Mini, multiple objects printed at the same time tend to get a lot of strings between them.
Step 6: Assembly
- Round bezel is press-fit
- Use a thin strand of FunTak or a thin bead of SuperGlue to fasten the rods to each side. Take care to press the front and side of the rods firmly and evenly into the channels on the case, rounded end toward the bezel
- Use a slightly longer screw (like 8mm) to 'tap' the mounting holes for the piTFT
- Carefully insert the pi zero male headers into the female headers of the piTFT
- Align the piTFT holes with the mounting posts in the case
- Use 3mm length screws to fasten the piTFT to the mounting holes
- If you have problems with M2.5, try M2 screws
- Attach a left-angle micro-USB adapter to the pi zero micro USB power jack
- Insert the power adapter plug
Power up!
Advanced Finishing Options
I really, REALLY wanted to get a chrome or gold metal effect on the outside decorations for the Art Deco Clock. I tried priming/sanding/spray painting. Results were...less than satisfactory. Some attempts left the surface rough and mottled. Others looked fine - until I picked it up with nitrile gloves on. The gloves left an imprint in the paint. That was even after letting the paint dry for 2 days. Bubbles started appearing.
Could have been my technique, could have been the metallic particles.
Try something else? I did lots of googling, and finally decided to give vinyl car wrap a try. You can get small rolls of this material, usually 12 inch x 48 inch or so, for $10-15 USD.
I did DOZENS of experiments on the front bezel and side rods with vinyl wrap, and found a process that was difficult, more art than science - but could get decent results. The key thing to remember is Stretch and Stick the material. If you look at Professional Car Wrap videos on youtube, the pro's use heat guns to stretch the material and remove wrinkles. Um, no. If you use a heat gun on PLA printed parts, they can start to soften and deform. Promptly after stretching, you'll want to stick the vinyl down, especially around edges/rims and in crevices. You may want to anchor the vinyl down on another piece of vinyl. Material that is not properly anchored down will eventually pull up.
Key Learnings:
- Lifetime: vinyl wrap is expected to last 5-7 years in exterior applications (cars)
- There is usually an almost-invisible film of plastic on top of the vinyl that must be removed for proper results
- You can easily stretch small amounts of the material by hand
- Vinyl sticks to itself very well!
- When trimming waste material, apply tension to the material you are removing and use long, continuous slicing strokes - don't saw
Check this video out:
Here are the results:
Comments