Pico Inky & Raspberry Pi Pico

Hi all,
Does anyone know if there are any micropython graphics libraries for the Pico Inky eink display.
The product page links to the general repo but I can’t find anything related to this display, other than specific libraries for the badger product.

Any help would be appreciated.

Thanks

Hello! It will be supported in MicroPython with the PicoGraphics graphics library (or you can install the Badger image on your Pico of course, though you might run into problems with the lack of buttons/them being on different pins).

Here’s a simple example using PicoGraphics I just added. Software support for this screen is being worked on as we speak though, so things like how pen ‘colours’/dither works might be subject to change! You’ll need to be running the latest, greatest MicroPython (v19.1).

# This example shows you a simple, non-interrupt way of reading Pico Inky Pack's buttons with a loop that checks to see if buttons are pressed.

import time
from pimoroni import Button
from picographics import PicoGraphics, DISPLAY_INKY_PACK

display = PicoGraphics(display=DISPLAY_INKY_PACK)

# you can change the update speed here!
# it goes from 0 (slowest) to 3 (fastest)
display.set_update_speed(2)

display.set_font("bitmap8")

button_a = Button(12)
button_b = Button(13)
button_c = Button(14)


# a handy function we can call to clear the screen
# display.set_pen(1) is white and display.set_pen(0) is black
def clear():
    display.set_pen(1)
    display.clear()


# set up
clear()
display.set_pen(0)
display.text("Press any button!", 10, 10, 240, 3)
display.update()
time.sleep(0.5)

while True:
    if button_a.read():                                   # if a button press is detected then...
        clear()                                           # clear to white
        display.set_pen(0)                                # change the pen colour
        display.text("Button A pressed", 10, 10, 240, 3)  # display some text on the screen
        display.update()                                  # update the display
        time.sleep(0.5)
    elif button_b.read():
        clear()
        display.set_pen(0)
        display.text("Button B pressed", 10, 50, 240, 3)
        display.update()
        time.sleep(0.5)
    elif button_c.read():
        clear()
        display.set_pen(0)
        display.text("Button C pressed", 10, 90, 240, 3)
        display.update()
        time.sleep(0.5)
    time.sleep(0.1)  # this number is how frequently the Pico checks for button presses
1 Like

That’s fantastic, thank you for your help.

Is anyone else able to run the more complex Pico Inky examples? Anything that pulls data over wireless complains about a missing urllib…?

Yep - same here. Getting “no module named ‘urllib’” running any of the networked inky examples with the latest 1.19.2 pimoroni UF2.

You can install the missing requests library via '‘Tools’ > ‘Manage Packages’ in Thonny - search for micropython-urllib.urequest

I’ll see if I can make that more obvious in the examples / on the shop page…

1 Like

Ahh! Thanks; I was probably hobbled by my complete lack of Micropython knowledge.

I did try looking for urllib as a package, didn’t think to add the urequest bit…

I am running Thonny 3.3.13 and have loaded pimoroni-picow-v1.19.6-micropython.uf2 onto the picow with an inky pack.

When I try to install the micropython-urllib.urequest using Tools->Manage packages, I get the following error. Basically, it is complaining about an expired certificate.

Has anyone else seen this error?
Is there another source for the library?
Any ideas?

Thanks,

Traceback (most recent call last):
File “C:\bin\Thonny\lib\urllib\request.py”, line 1350, in do_open
encode_chunked=req.has_header(‘Transfer-encoding’))
File “C:\bin\Thonny\lib\http\client.py”, line 1277, in request
self._send_request(method, url, body, headers, encode_chunked)
File “C:\bin\Thonny\lib\http\client.py”, line 1323, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “C:\bin\Thonny\lib\http\client.py”, line 1272, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “C:\bin\Thonny\lib\http\client.py”, line 1032, in _send_output
self.send(msg)
File “C:\bin\Thonny\lib\http\client.py”, line 972, in send
self.connect()
File “C:\bin\Thonny\lib\http\client.py”, line 1447, in connect
server_hostname=server_hostname)
File “C:\bin\Thonny\lib\ssl.py”, line 423, in wrap_socket
session=session
File “C:\bin\Thonny\lib\ssl.py”, line 870, in _create
self.do_handshake()
File “C:\bin\Thonny\lib\ssl.py”, line 1139, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1091)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\bin\Thonny\lib\tkinter_init_.py”, line 1705, in call
return self.func(*args)
File “C:\bin\Thonny\lib\tkinter_init_.py”, line 749, in callit
func(*args)
File “C:\bin\Thonny\lib\site-packages\thonny\plugins\micropython\pip_gui.py”, line 438, in poll_fetch_complete
_, bin_data = url_future.result()
File “C:\bin\Thonny\lib\concurrent\futures_base.py”, line 428, in result
return self.__get_result()
File “C:\bin\Thonny\lib\concurrent\futures_base.py”, line 384, in __get_result
raise self._exception
File “C:\bin\Thonny\lib\concurrent\futures\thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “C:\bin\Thonny\lib\site-packages\thonny\plugins\pip_gui.py”, line 1230, in load_url
with urlopen(url, timeout=timeout) as conn:
File “C:\bin\Thonny\lib\urllib\request.py”, line 222, in urlopen
return opener.open(url, data, timeout)
File “C:\bin\Thonny\lib\urllib\request.py”, line 525, in open
response = self._open(req, data)
File “C:\bin\Thonny\lib\urllib\request.py”, line 543, in _open
‘_open’, req)
File “C:\bin\Thonny\lib\urllib\request.py”, line 503, in _call_chain
result = func(*args)
File “C:\bin\Thonny\lib\urllib\request.py”, line 1393, in https_open
context=self._context, check_hostname=self._check_hostname)
File “C:\bin\Thonny\lib\urllib\request.py”, line 1352, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1091)>

Ooh yes, I came across this with my home computer - it’s a Windows error caused by out of date security certificates

I fixed it by updating the Windows root certificate: SSL: CERTIFICATE_VERIFY_FAILED, certificate has expired · Issue #1986 · thonny/thonny · GitHub

If you’d rather not do that, there’s an mpy compiled version of the urllib library here: pimoroni-pico/micropython/examples/common at main · pimoroni/pimoroni-pico · GitHub - copy it the ‘lib’ directory on your Pico using Thonny.

1 Like

Thanks. I appreciate the help.

I also have a problem with installing micropython-urllib.urequest, I get following error, over and over again:

C:\Users\Gebruiker\AppData\Local\Programs\Thonny\python.exe -m pip --disable-pip-version-check --no-color install --no-warn-script-location --user --user micropython-urllib.urequest
Collecting micropython-urllib.urequest
Using cached micropython-urllib.urequest-0.6.3.tar.gz (2.1 kB)
ERROR: micropython-urllib.urequest from https://files.pythonhosted.org/packages/d2/b9/4943f9fc6f60a8f7e0a2ad2a8c96973a94dda20d85e225c0b0348ba4c357/micropython-urllib.urequest-0.6.3.tar.gz does not appear to be a Python project: neither ‘setup.py’ nor ‘pyproject.toml’ found.
Error: process returned with code 1

I’d like to try the second option of this answer, but Thonny is always complaining that it can’t read the file as UTF-8 text.
Any idea how I might get this to work?

If you’re installing via Thonny, double check you’re using ‘Manage Packages’, not ‘Manage Plug-ins’ (the dialogues look very alike!)

Alternatively, you can download our whole repo to your computer by running git clone https://github.com/pimoroni/pimoroni-pico in a terminal or (if you don’t want to use the terminal) by clicking the green ‘<> Code’ button’ and choosing ‘Download ZIP’ on the front page of the repo. Once you’ve got pimoroni-pico downloaded locally, you can browse to the files you want to copy to your Pico/Inky Frame in the top Files box, and right click and ‘Upload to /’ to transfer them. I usually just grab all the files in \micropython\examples\common in one swoop:

1 Like

Ok, I was indeed to install the missing library in ‘Manage Plug-ins’ instead of ‘Manage Packages’. Still have some problems but I’ll try to get it to work again this weekend, if I can’t get it to work then I’ll be back.

Ok, problems solved, it works like a charm, thanks a lot!

1 Like

I’ve also been having problems with this. While I THINK I’ve got the urllib installed, I’m getting the following when trying to get the URL in the news example:

try get_rss
Traceback (most recent call last):
File “”, line 157, in
File “”, line 139, in get_rss
File “urllib/urequest.py”, line 62, in urlopen
NotImplementedError: Redirects not yet supported

The odd thing is that at one stage I had “Error: Unable to get feed :(” displayed on the inky frame!
I suspect it’s partly due to poor WiFi reception on the Pico (intermittent problems are fun aren’t they).

See BadgerW News example: Redirects not yet supported - #3 by richieeee - the problem is that, well, redirects aren’t supported and the URLs in the news example are redirected.

(given this is the third time I’ve seen this asked in a week, maybe I’ll just send in a PR!)

1 Like

I did a PR yesterday for badger2040 😀 as I could see someone else getting stuck.

2 Likes

I’m glad I didn’t get around to doing it myself then :-)

Thank you! I can now remove my diagnostics (which had extended so far to messing with the LEDs and probably causing other issues) ;-)