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 Bundle button, 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 CIRCUITPY drive.

# SPDX-FileCopyrightText: 2019 Isaac Wellish for Adafruit Industries
# SPDX-License-Identifier: MIT

'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

Used libraries

This project uses the following CircuitPython libraries loaded in the Project Bundle:

  • 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_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 20, 2024.

This page (Download Project Files from GitHub) was last updated on Feb 10, 2024.

Text editor powered by tinymce.