Make A Gudetama Clock with Inky pHAT

So I made a Gudetama-themed clock ran on a Raspberry Pi Zero W with an Inky pHAT e-paper display.

 

I have a Zero W laying around and I decided to get an Inky pHAT completely out of curiosity, not knowing what to do with the low-cost e-paper display. I then realized the yellow version of the Inky pHAT displays an orangy yellow. This is when the idea of a Gudetama clock was spawned.

As you can see, there’s on the top-left corner, the weather and temperature. On the right side of the screen, you will have different Gudetamas according to different times or dates. And, of course, there’s a time telling line.

Fresh out of the bag, there’s nothing you need to do as it comes fully assembled. However, I need to hammer a male GPIO header onto the Zero W, which was a bit tricky.

 

I was surprised that the physical installation of the Inky pHAT was very straightforward. You just pop the display into the GPIO pins, done. People have used the Inky pHAT as a name tag and remove it from the header. I actually do not advise doing so very often because Inky pHAT fits snugly in the GPIO header. I accidentally bent some of the GPIO pins when removing the Inky pHAT from the header. Popping it back to the header straightens the pins, but, boy, I was traumatized.

Installing the software

Before installing the Inky pHAT software, you should make sure your Raspbian OS is up-to-date. Although I installed a fresh OS, I still updated the OS just to be sure,

sudo apt-get update

sudo apt-get upgrade

Then we can get the Inky pHAT software.

curl https://get.pimoroni.com/inky | bash

 

Forking the GitHub repository

The Gudetama Clock runs on several scripts, which I have uploaded to GitHub. You should fork (copy) the GitHub repository so you can adjust the scripts yourself.

  1. Navigate to the GitHub.
  2. In the top-right corner of the page, click Fork.

After forking the repo, there are important changes to be made in order for the scripts to run without errors.

First and foremost, we have to obtain an API key from OpenWeather.

  1. Navigate to OpenWeather.
  2. Sign up and subscribe to the free Current Weather Data API.
  3. In your confirmation email, copy your API key.
  4. Replace 'YOUR OPENWEATHER API KEY' in line 7 of weather.py with your API key.
  5. Replace 'CITY', 'STATE/PROVINCE' (leave it '' if you need), and 'COUNTRY' with your location.
  6. Save it by clicking Commit Changes.

Secondly, we would want to adjust the moonphase.py.

  1. Google your lat and long, and UTC offset of your location
  2. Replace 'LAT', 'LONG' and 'OFFSET'
  3. Save it by clicking Commit Changes.

 

Cloning the repo

All should be ready to deploy.

we need to create a directory for our git repo. Go to the terminal and type:

sudo mkdir /home/pi/clock

cd /home/pi/clock

Now that we have created our directory, we can then clone the repository.

git clone https://github.com/---YOUR USERNAME---/gudetamaclock.git

Voilà!

 

Running the script

we should try to run the script to make sure it works.

  1. Further navigate the directory by cd /home/pi/clock/gudetamaclock
  2. Enterpython3 clock.py

It takes approximately 15 seconds for the image to fully develop.

 

Automating the script

If the script runs okay, we can automate it to run every 5 minutes. The reason I chose 5 minutes instead of every minute is Inky pHAT is an e-paper display and as you can see it takes time for the image to appear on the display. Although it is possible to run the script every minute, at the same time, it is odd to have the screen spending 1/4 of the time flickering.

crontab -e

At the bottom of the script, enter:

*/5 * * * * python3 /home/pi/clock/gudetamaclock/clock.py

That will run and update the clock every 5 minutes.

Leave a Reply

Your email address will not be published. Required fields are marked *