Twitter Follower Display Using PyPortal and CircuitPython
I found myself with the desire to display my Twitter follower account at my desk so that I can feed my ever-growing narcissism. In my journey around the internet I found the PyPortal Titano from Adafruit. It combines a 3.5″ resistive touch screen with an ESP32 in a thin package running CircuitPython that’s built for exactly this task.
If you too find yourself wanting to grow your need to feel wanted then read on. This guide is created using information from Adafruit’s own guide written by John Park. I have modified some of the information to be more concise and allow you to get up and running quickly.
Prepare the PyPortal
If you have already configured your PyPortal and just want the code then scroll down to the code section.
Plugin the PyPortal to your computer using the USB-C cable. Once the device boots, your computer will mount a drive called CIRCUITPY. Open the drive and delete all of the files.
Click above to download the project code. Extract the zip file and drag the entire contents of the extracted folder to the CIRCUITPY drive. The PyPortal will reboot but you don’t need to wait for it. Any time you change the contents of the CIRCUITPY drive by either adding/removing files or changing code, the PyPortal will soft reboot.
Configure the Twitter account.
Note: All code changes from this point are done from the CIRCUITPY drive.
code.py and edit line 11 replacing
spaceboyr00 with the Twitter username that you want to track. Optionally, if you would like to display this username at the bottom of the PyPortal, uncomment lines 32 through 35. In either case, save the file and wait for the PyPortal to reboot.
secrets.py and edit line 7 replacing
SSID with the name of your Wi-Fi network. On line 8, replace
PASSWORD with the password for you Wi-Fi network. Do not share this information and do not place it anywhere other than
secrets.py. Save the file and wait for the PyPortal to reboot.
After about 20 seconds the PyPortal should display the follower count. If not, read back through each step and double-check the work.
I have included two images in the zip file above; One for the PyPortal startup and another for the main background. I have designed these to match my own style and you can do the same. To customize either image, replace it with a 320 x 480 bitmap with the same name as the one you intend to overwrite.
Customizing text alignment.
The PyPortal positions text with the origin being in vertical center of the left edge. I have chosen to center the text but this could cause alignment issues for accounts that have more or less digits than my account. If you find that the follower count is not centered properly, adjust the first number on line 28. A lower number moves the count left and a higher number moves it right.
If you have any questions hit me up on Twitter at @spaceboyr00. If you build your own PyPortal project be sure to share it with me! I love to see what others are making!