If you have not yet set up a settings.toml file in your CIRCUITPY drive and connected to the internet using it, follow the directions in the Create Your settings.toml File and Internet Connect! pages in this guide.
You will need your Adafruit IO username, and Adafruit IO key. Head to io.adafruit.com and simply click the View AIO Key link on the left hand side of the Adafruit IO page to get this information.
Then, add them to the settings.toml file:
CIRCUITPY_WIFI_SSID = "your_wifi_ssid" CIRCUITPY_WIFI_PASSWORD = "your_wifi_password" AIO_USERNAME = "your_aio_username" AIO_KEY = "your_aio_key"
Add CircuitPython Code and Project Assets
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_Email_Display.
Copy the contents of the PyPortal_Email_Display directory to your PyPortal's CIRCUITPY drive. Make sure to save the font (Helvetica-Oblique-17.bdf) into the fonts folder on the CIRCUITPY drive.
This is what the final contents of the CIRCUITPY drive will look like:
# SPDX-FileCopyrightText: 2019 Brent Rubell for Adafruit Industries # # SPDX-License-Identifier: MIT """ PyPortal Adafruit IO Feed Display Displays an Adafruit IO Feed on a PyPortal. """ import time import board from adafruit_pyportal import PyPortal # Get Adafruit IO details and more from a secrets.py file try: from secrets import secrets except ImportError: print("Adafruit IO secrets are kept in secrets.py, please add them there!") raise # Adafruit IO Account IO_USER = secrets['aio_username'] IO_KEY = secrets['aio_key'] # Adafruit IO Feed IO_FEED = 'zapemail' DATA_SOURCE = "https://io.adafruit.com/api/v2/{0}/feeds/{1}?X-AIO-Key={2}".format(IO_USER, IO_FEED, IO_KEY) FEED_VALUE_LOCATION = ['last_value'] cwd = ("/"+__file__).rsplit('/', 1)[0] pyportal = PyPortal(url=DATA_SOURCE, json_path=FEED_VALUE_LOCATION, status_neopixel=board.NEOPIXEL, default_bg=cwd+"/pyportal_email.bmp", text_font=cwd+"/fonts/Helvetica-Oblique-17.bdf", text_position=(30, 65), text_color=0xFFFFFF, text_wrap=35, # wrap feed after 35 chars text_maxlen=160) # speed up projects with lots of text by preloading the font! pyportal.preload_font() while True: try: print('Fetching Adafruit IO Feed Value..') value = pyportal.fetch() print("Response is", value) except RuntimeError as e: print("Some error occured, retrying! -", e) time.sleep(10)
After the PyPortal loads up (it will display a startup image and sound), it will display an image called email_background.bmp
as the screen's background. This is a 320 x 240 pixel RGB 16-bit raster graphic in .bmp format.
Then, it requests the value of the Adafruit IO feed (IO_FEED
in the code) and displays the value with bitmapped fonts on top of the background.
- Want to use your own fonts? Learn more about PyPortal fonts in this guide.
When the custom inbox is emailed, Zapier will immediately send the data to an Adafruit IO feed.
Customization
Now that you have your PyPortal displaying incoming emails, you add some customization to the PyPortal to give your personal flair!
Change the background
You can customize the background to add (or remove) information, by making a 320x240 16-bit RGB color .bmp file.
Display more text
Want to show more text on the display? While our code limits the maximum length of the feed value being displayed to 160 characters, you can change it in the code by increasing the length of the variable text_maxlen
to any amount of characters which can fit reasonably on the display.
If you want to display more text, switch to a smaller font size.
Change the text color
You can also change the color of the display by changing the line text_color=0xFFFFFF
in the code to your color of choice.
Visit https://www.color-hex.com to pick your color, and then adjust the text_color
value.
For example, if you'd like to change the text from white to black, you'd adjust the text_color from text_color=0xFFFFFF
to text_color=#000000
Text editor powered by tinymce.