PokeInkDis - Python Pokemon E-Ink Display for Raspberry Pi


Short version:

Displays a random pokemon with weather stats.
Needs to be passed a Dark Sky API key (free) and your coordinates.
python3 PokeInkDis.py -dskey XX -lat XX -lon XX
-j puts display in Japanese
-f puts temperature in °F
-g limits to a specific pokemon generation (-g 2 for Johto)
-p forces a specific pokemon (-p 25 for Pikachu)


Long version:

I bought a Raspberry Pi Zero W and an eink screen, and was trying to think of something interesting to do with it.

I decided on showing a random pokemon every day, along with the weather and some visitor stats for my (this) website.

The eink screen I chose is very cool, it has white, black, and red. (I think it's an E Ink Spectra, I've seen these 3 color screens being used in some stores to display the price of items, 12% of E Ink's revenue comes from price labels)

I assumed it supported greyscale too, but no - when I got it I realized it really only has 3 colors. Some pokemon look a bit strange with only 3 colors, but most of them are ok, I'm happy with the result.

The screen's resolution is only 212x104, so I didn't have much room to work with.
The pokemon sprites I used are 96x96, so they just fit in with 4 'pixels' to spare on the top and bottom. The pokemon sprites are from Black/White 2. The later games don't have 2d sprites (right?) - so that's why sixth gen and up isn't supported.

My program is in Python 3, and connects to the eink screen using the inkyphat library made by Pimoroni. They created the library for their eink screens that they sell.
To be honest, I didn't use their screen, I found a cheaper (at the time) alternative on ebay from company called Waveshare, and modified their library to make it compatable after finding this page. Thank you boeeerb!
I only used the inkyphat library to push the image to the eink screen, to build the actual image I used PIL.

I tried to annotate the code and explain what's going on, so maybe someone can learn from what I did, or edit it and make their own changes.
If there are any questions please ask!

For the weather icons, I'm using a weather icon font - https://erikflowers.github.io/weather-icons/ - clever name.
I choose what icon gets drawn by getting the weather status from Dark Sky and matching that up to the correct unicode value for the font from a json file I made. Then I simply draw that character just like any string.
PIL's text renderer doesn't seem to be that good, because I'm sure the weather icon should look better than it does. I'm sure if I rendered it at a larger size and then scaled it down it would look better.

The font for all the text is a cool free pixel/bitmap font - https://osdn.net/projects/mix-mplus-ipa/releases/58930

You can see in the pictures I have shared that my personal version displays site visitor statistics. I have removed that code from the public version, so there will just be a blank space for you.

I thought about keeping a log of the previous random pokemon that have been displayed, so that you won't get the same pokemon in a row, or a few days later - I might add that functionality later.

I found a cool little holder/case for the Pi and eink screen which you can see in my pictures - https://coretecrobotics.co.uk/collections/frontpage/products/phatbadge - it works great. Because that case is meant for the inkyphat screens, the Waveshare screen needed a connector broken off (pliers did it in 10 seconds), and the plastic case needs a little filing or sanding down to make room for a pcb component.

How to set it up:

  1. Set up almost everything needed to get the eink screen working:
    curl https://get.pimoroni.com/inkyphat | bash
  2. Next, downgrade to the old version because the 1.0 seems to have some bugs, and I know v0.1.1 works:
    sudo pip3 install --upgrade inkyphat==0.1.1
  3. I noticed numpy needs libatlas to work (not sure why not installed in the inkyphat installer):
    sudo apt-get install libatlas-base-dev
  4. Optional, if you want to play with the examples, delete the Pimoroni folder in your home directory because those are for v1.0 and we downgraded, and should use this: https://github.com/pimoroni/inky-phat/archive/v0.1.1.zip
  5. If you are using a waveshare eink screen (like me) and not the inkyphat screen, edit the inkpyhat library:
    Find the file that we need to edit: sudo find / -name inky212x104.py
    Copy that file path, open it in something like nano and change these values:
    RESET_PIN = 27 BUSY_PIN = 17 DC_PIN = 22
    RESET_PIN = 17 BUSY_PIN = 24 DC_PIN = 25

Now, my program should run for you.

How to use:

Download from here - https://github.com/llakssz/PokeInkDis/releases/latest
Sign up for a free (limited to 1000 calls a day) Dark Sky account and get an API key.
Get the latitude and longitude of your location.

python3 PokeInkDis.py -dskey XX -lat XX -lon XX
-j puts display in Japanese
-f puts temperature in °F
-g limits to a specific pokemon generation (-g 2 for Johto)
-p forces a specific pokemon (-p 25 for Pikachu)

If you want PokeIndDis.py to run automatically:

Let's assume PokeInkDis.py is in ~/PokeInkDis/
First, in your home directory:
nano run_pokeinkdis.sh
Enter these 3 lines (plus any options to PokeInkDis.py you want):

cd PokeInkDis
python3 PokeInkDis.py -dskey YOUR_DARKSKY_API_KEY -lat YOUR_LAT -lon YOUR_LON

Save and exit nano (Ctrl o, Ctrl x)

Make our script able to be executed:
chmod u+x run_pokeinkdis.sh

Now we have a shell script to run PokeInkDis.

To make PokeInkDis run every day at 3am:

crontab -e
Choose nano, then enter this:
0 3 * * * /home/pi/run_pokeinkdis.sh

To set up a service to start the program at boot, after we have internet.

sudo systemctl edit --force --full pokeinkdis.service
For me, nano opens up, paste into it:




More pictures: