All of the files required for this project (the code, graphics, and font) are available for download on GitHub. There are two code files for this project, our regular along with

You'll need to edit with your applicable information. You can find more info on all of the code files in the next two pages of this guide.

CircuitPython Code

In the embedded code element below, click on the Download: Project Zip link, and save the .zip archive file to your computer.

Then, uncompress the .zip file, it will unpack to a folder named PyPortal_on_this_day.

Copy the contents of the PyPortal_on_this_day directory to your PyPortal's CIRCUITPY drive.

'of this day' demo
Display notable info about famous electronics-related peoples
Data sources:

import time
import board
from adafruit_pyportal import PyPortal

cwd = ("/"+__file__).rsplit('/', 1)[0] # the current working directory (where this file is)

DAY = ["Day of the year"]
PERSON = ["Person"]
NOTABLE = ["Notable for"]
YEAR = ["Year"]
ACCOMPLISH = ["Accomplishment"]
WEB = ["Web Reference"]


# a function that returns whatever is passed in
def identity(x):
    return x

# create pyportal object w no data source (we'll feed it text later)
pyportal = PyPortal(url = BASE_DATA, debug=True,
                    json_path = (DAY, PERSON, NOTABLE, YEAR, ACCOMPLISH, WEB),
                    status_neopixel = board.NEOPIXEL,
                    default_bg = cwd + "/on_this_day_bg.bmp",
                    text_font = cwd+"fonts/Arial-ItalicMT-17.bdf",
                    text_transform = [identity]*6,  # we do this so the date doesnt get commas
                    text_position=((10, 70), (10, 100), (10, 130),(60, 160), (105, 190), (10, 220)),
                    text_color=(0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF),
                    text_maxlen=(50, 50, 50, 50, 50, 50), # cut off characters

while True:
        print("Getting time from internet!")
        refresh_time = time.monotonic()
    except RuntimeError as e:
        print("Some error occured, retrying! -", e)

    now = time.localtime()
    print("Current time:", now)
    url = BASE_DATA+"%02d_%02d.json" % (now.tm_mon, now.tm_mday)
    response = None
        response = pyportal.fetch(url)
        print("Response is", response)
    except RuntimeError as e:
        print("Some error occured, retrying! -", e)

    # Make a QR code from web reference
    pyportal.show_QR(bytearray(response[5]), qr_size=3,
                     x=220, y=10)

    # wait 10 minutes before running again

Downloading the libraries

Per the CircuitPython Libraries page previously, download the library bundle appropriate for your version of CircuitPython. Copy the below library files/folders to a directory named lib on your CIRCUITPY drive.

Make sure to add the necessary libraries to the lib folder, info on how to do this can be found in the "PyPortal CircuitPython Setup" section

This project uses the following CircuitPython libraries:

  • adafruit_bitmap_font (directory)
  • adafruit_bus_device (directory)
  • adafruit_display_shapes (directory)
  • adafruit_display_text (directory)
  • adafruit_esp32spi (directory)
  • adafruit_io (directory)
  • adafruit_miniqr.mpy (file)
  • adafruit_pyportal.mpy (file)
  • adafruit_requests (file)
  • adafruit_sdcard.mpy (file)
  • adafruit_touchscreen.mpy (file)
  • neopixel.mpy (file)

This is what the final contents of the CIRCUITPY drive will look like:

Double check

See the directory listing above and double check that you have all the files listed to make this project function. If any are missing or in an incorrect directory, move them so they're in the right places. The project will not work correctly unless the files are in the right locations.

This guide was first published on Feb 05, 2020. It was last updated on Feb 05, 2020.

This page (Download Project Files from GitHub) was last updated on Oct 11, 2020.