
Language Flashcards on the MagTag
Created by Lucian Copeland
Last updated on 2021-04-15 08:19:06 PM EDT

2
3
4
8
8
9
9
10
11
12
12
13
13
14
18
18
18
18
19
22
22
22
23
23
25
25
28
28
32
33
34
34
37
38
40
42
42
Guide Contents
Guide Contents
Overview
Parts
Install CircuitPython
Set Up CircuitPython
Option 1 - Load with UF2 Bootloader
Try Launching UF2 Bootloader
Option 2 - Use esptool to load BIN file
Option 3 - Use Chrome Browser To Upload BIN file
CircuitPython Internet Libraries
Adafruit CircuitPython Library Bundle
CircuitPython Internet Test
Secrets File
Connect to WiFi
Getting The Date & Time
Step 1) Make an Adafruit account
Step 2) Sign into Adafruit IO
Step 3) Get your Adafruit IO Key
Step 4) Upload Test Python Code
MagTag-Specific CircuitPython Libraries
Get Latest Adafruit CircuitPython Bundle
Secrets
Simple Flashcards
Download the Software
Example Deck
How does it work?
Complicated Flashcards
Download the Software
New Deck Format
Program Flow
Code Walkthrough
Setup:
Chapter Selection:
Flashcard Session:
Wrapping up:
Other Resources
Font License:
© Adafruit Industries https://learn.adafruit.com/magtag-flashcards Page 2 of 43

Overview
When you’re studying something that needs a lot of memorization, like learning a language, prepping for a
tough biology exam, or mastering all those pesky built-in Python functions, it’s hard to beat a good old
deck of flashcards. It’s the tried and true method of getting tough subjects to stick to your grey matter especially when you’re on a deadline, and you’ve really got to get this stuff
down
or you are going to
flunk
most heinously tomorrow, dude!
But like many old fashioned methods, flashcards can be kind of a pain! You have to spend ages writing
them all out on paper, and then somebody knocks them off the table and one goes under the fridge, and
then your buddy asks to borrow them but you’re not
finished
and you’re not going to make him a
whole
other deck,
are you
kidding,
and now the edges have gotten all bent so they don’t shuffle well any more,
and then once you’ve finally gotten everything memorized there’s nothing to do but toss them all out and
get started on the next deck. The results may be good, but the process? Frustrating.
Enter the MagTag!
With CircuitPython, you can type out your flashcards in JSON, and you’ll never be stuck writing and
shuffling huge decks of index cards again. You can sort them by chapters, support lots of different
international fonts, even share them with your slacker buddy with a simple copy-paste. Maybe not the
most
old-fashioned anymore, but it’s e-paper, so we’re pretty sure it still counts.
Thanks to Unicode font support in CircuitPython, you can quickly and easily make text for
any language
using free fonts!
© Adafruit Industries https://learn.adafruit.com/magtag-flashcards Page 3 of 43

This guide uses the e-paper and other hardware features of the MagTag, but note that it does not
use any of the ESP32-S2 networking capabilities (WIFI, etc). Setting up WIFI is included in the
installation process for completeness, but the final project will not connect to the internet, so you can
skip those steps if you want! Just install Circuitpython and the libraries, and don't worry about
secrets.py or the internet tests. If you'd specifically like to do a connected IoT project, we've got lots of
other guides to do that - check out the full list Magtag tutorials for ideas!
Parts
The MagTag starter kit comes with a battery and some magnets included. You'll also need to grab a USB
C cable separately, if you don't have one:
Adafruit MagTag Starter Kit - 2.9" Grayscale E-Ink WiFi Display
The Adafruit MagTag combines the new ESP32-S2 wireless module and a 2.9" grayscale E-Ink display to
make a low-power IoT display that can show data on its screen...
Out of Stock
Out of
Stock
© Adafruit Industries https://learn.adafruit.com/magtag-flashcards Page 4 of 43

USB Type A to Type C Cable - approx 1 meter / 3 ft long
As technology changes and adapts, so does Adafruit. This USB Type A to Type C cable will help you with
the transition to USB C, even if you're still...
$4.95
In Stock
Alternatively, you can get the parts individually, if you'd like to swap out the battery or omit the magnets.
Add to Cart
© Adafruit Industries https://learn.adafruit.com/magtag-flashcards Page 5 of 43

Adafruit MagTag - 2.9" Grayscale E-Ink WiFi Display
The Adafruit MagTag combines the new ESP32-S2 wireless module and a 2.9" grayscale E-Ink display to
make a low-power IoT display that can show data on its screen even when power...
Out of Stock
Out of
Stock
© Adafruit Industries https://learn.adafruit.com/magtag-flashcards Page 6 of 43

Lithium Ion Polymer Battery with Short Cable - 3.7V 420mAh
Lithium ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light and powerful. The output
ranges from 4.2V when completely charged to 3.7V. This battery...
$6.95
In Stock
Mini Magnet Feet for RGB LED Matrices (Pack of 4)
Got a glorious RGB Matrix project you want to mount and display in your workspace or home? If you have
one of the matrix panels listed below, you'll need a pack of these...
$2.50
In Stock
Add to Cart
Add to Cart
© Adafruit Industries https://learn.adafruit.com/magtag-flashcards Page 7 of 43

Install CircuitPython
CircuitPython (https://adafru.it/tB7) is a derivative of MicroPython (https://adafru.it/BeZ) designed to simplify
experimentation and education on low-cost microcontrollers. It makes it easier than ever to get
prototyping by requiring no upfront desktop software downloads. Simply copy and edit files on the
CIRCUITPY drive to iterate.
Set Up CircuitPython
Follow the steps to get CircuitPython installed on your MagTag.
https://adafru.it/OBd
Click the link above and download the latest .BIN and .UF2
file
(depending on how you program the ESP32S2 board you may
need one or the other, might as well get both)
Download and save it to your desktop (or wherever is handy).
Plug your MagTag into your computer using a known-good
USB cable.
A lot of people end up using charge-only USB cables and it is
very frustrating! So make sure you have a USB cable you
know is good for data sync.
https://adafru.it/OBd
© Adafruit Industries https://learn.adafruit.com/magtag-flashcards Page 8 of 43

Option 1 - Load with UF2 Bootloader
This is by far the easiest way to load CircuitPython. However it requires your board has the UF2
bootloader installed. Some early boards do not (we hadn't written UF2 yet!) - in which case you can load
using the built in ROM bootloader.
Still, try this first!
Try Launching UF2 Bootloader
Loading CircuitPython by drag-n-drop UF2 bootloader is the
easier way and we recommend it. If you have a MagTag
where the front of the board is black, your MagTag came with
UF2 already on it.
Launch UF2 by double-clicking the Reset button (the one next
to the USB C port). You may have to try a few times to get the
timing right.
If the UF2 bootloader is installed, you will see a new disk
drive appear called MAGTAGBOOT
© Adafruit Industries https://learn.adafruit.com/magtag-flashcards Page 9 of 43

Copy the UF2 file you downloaded at the first step of this
tutorial onto the MAGTAGBOOT drive
If you're using Windows and you get an error at the end of the file copy that says Error from the file copy,
Error 0x800701B1: A device which does not exist was specified. You can ignore this error, the bootloader
sometimes disconnects without telling Windows, the install completed just fine and you can continue. If its
really annoying, you can also upgrade the bootloader (the latest version of the UF2 bootloader fixes this
warning) (https://adafru.it/Pfk)
Your board should auto-reset into CircuitPython, or you may
need to press reset. A CIRCUITPY drive will appear. You're
done! Go to the next pages.
Option 2 - Use esptool to load BIN file
If you have an original MagTag with while soldermask on the front, we didn't have UF2 written for the
ESP32S2 yet so it will not come with the UF2 bootloader.
You can upload with esptool to the ROM (hardware) bootloader instead!
Follow the initial steps found in the Run esptool and check
connection section of the ROM Bootloader
page (https://adafru.it/OBc) to verify your environment is set
up, your board is successfully connected, and which port it's
using.
In the final command to write a binary file to the board,
replace the port with your port, and replace "firmware.bin"
with the the file you downloaded above.
The output should look something like the output in the
image.
© Adafruit Industries https://learn.adafruit.com/magtag-flashcards Page 10 of 43

Press reset to exit the bootloader.
Your CIRCUITPY drive should appear!
You're all set! Go to the next pages.
Option 3 - Use Chrome Browser To Upload BIN file
If for some reason you cannot get esptool to run, you can always try using the Chrome-browser version of
esptool we have written. This is handy if you don't have Python on your computer, or something is really
weird with your setup that makes esptool not run (which happens sometimes and isn't worth debugging!)
You can follow along on the Web Serial ESPTool (https://adafru.it/Pdq) page and either load the UF2
bootloader and then come back to Option 1 on this page, or you can download the CircuitPython BIN file
directly using the tool in the same manner as the bootloader.
© Adafruit Industries https://learn.adafruit.com/magtag-flashcards Page 11 of 43

CircuitPython Internet Libraries
To use the internet-connectivity built into your ESP32-S2 with CircuitPython, you must first install a number
of libraries. This page covers that process.
Adafruit CircuitPython Library Bundle
Download the Adafruit CircuitPython Bundle. You can find the latest release here:
https://adafru.it/ENC
Download the adafruit-circuitpython-bundle-version-mpy-*.zip bundle zip file, and unzip a folder of the
same name. Inside you'll find a lib folder. The entire collection of libraries is too large to fit on
the CIRCUITPY drive. Instead, add each library as you need it, this will reduce the space usage but you'll
need to put in a little more effort.
At a minimum we recommend the following libraries, in fact we more than recommend. They're basically
required. So grab them and install them into CIRCUITPY/lib now!
adafruit_requests.mpy - A requests-like library for HTTP commands.
neopixel.mpy - Helper library to use NeoPixel LEDs, often built into the boards so they're great for
quick feedback
Once you have added those files, please continue to the next page to set up and test Internet connectivity
https://adafru.it/ENC
© Adafruit Industries https://learn.adafruit.com/magtag-flashcards Page 12 of 43

CircuitPython Internet Test
Once you have CircuitPython installed and the minimum libraries installed we can get your board
connected to the Internet.
To get connected, you will need to start by creating a secrets.py file.
Secrets File
We expect people to share tons of projects as they build CircuitPython WiFi widgets. What we want to
avoid is people accidentally sharing their passwords or secret tokens and API keys. So, we designed all
our examples to use a secrets.py file, that is in your CIRCUITPY drive, to hold secret/private/custom data.
That way you can share your main project without worrying about accidentally sharing private stuff.
Your secrets.py file should look like this:
# This file is where you keep secret settings, passwords, and tokens!
# If you put them in the code you risk committing that info or sharing it
secrets = {
'ssid' : 'home_wifi_network',
'password' : 'wifi_password',
'aio_username' : 'my_adafruit_io_username',
'aio_key' : 'my_adafruit_io_key',
'timezone' : "America/New_York", # http://worldtimeapi.org/timezones
}
Copy and paste that text/code into a file called secrets.py and save it to your CIRCUITPY folder like so:
Inside is a python dictionary named secrets with a line for each entry. Each entry has an entry name
(say 'ssid' ) and then a colon to separate it from the entry key 'home ssid' and finally a comma ,
At a minimum you'll need to adjust the ssid and password for your local WiFi setup so do that now!
As you make projects you may need more tokens and keys, just add them one line at a time. See for
example other tokens such as one for accessing github or the hackaday API. Other non-secret data like
your timezone can also go here, just cause its called secrets doesn't mean you can't have general
customization data in there!
© Adafruit Industries https://learn.adafruit.com/magtag-flashcards Page 13 of 43