NeoPixel LED - This addressable RGB NeoPixel LED, labeled Neo on the board,
•
works both as a status LED (in CircuitPython and the bootloader), and can be
controlled with code. It is available in CircuitPython as board.NEOPIXEL , and in
Arduino as PIN_NEOPIXEL .
There is a NeoPixel power pin that needs to be pulled high for the NeoPixel to
•
work.This is done automatically by CircuitPython. You must manually do this in
Arduino. It is available in CircuitPython and Arduino as NEOPIXEL_POWER .
Red LED - This little red LED, labeled #13 on the board, is on or blinks during
•
certain operations (such as pulsing when in the bootloader), and is controllable
in code. It is available in CircuitPython as board.LED , and in Arduino as
LED_BUILTIN or 13 .
The NEOPIXEL_POWER pin must be pulled high in Arduino for the NeoPixel LED
This JST SH 4-pin STEMMA QT(https://adafru.it/Ft4) connector breaks out I2C (SCL,
SDA, 3.3V, GND). It allows you to connect to various breakouts and sensors with STEM
MA QT connectors(https://adafru.it/Qgf) or to other things usingassorted associated
accessories(https://adafru.it/Ft6). It works great with any STEMMA QT or Qwiic
sensor/device. You can also use it with Grove I2C devices thanks to this handy cable(
https://adafru.it/Ndk).
There is a power pin that must be pulled high for the STEMMA QT connector to work.
This is done automatically by CircuitPython. You must manually do this in Arduino. The
pin is available in CircuitPython and in Arduino as TFT_I2C_POWER .
The TFT_I2C_POWER pin must be manually pulled high in Arduino for the
When CircuitPython finishes installing, or you plug a CircuitPython board into your
computer with CircuitPython already installed, the board shows up on your computer
as a USB drive called CIRCUITPY.
The CIRCUITPY drive is where your code and the necessary libraries and files will live.
You can edit your code directly on this drive and when you save, it will run
automatically. When you create and edit code, you'll save your code in a code.py file
located on the CIRCUITPY drive.If you're following along with a Learn guide, you can
paste the contents of the tutorial example into code.py on the CIRCUITPY drive and
save it to run the example.
With a fresh CircuitPython install, on your CIRCUITPY drive, you'll find a code.py file
containing print("Hello World!") and an empty lib folder. If your CIRCUITPY
drive does not contain a code.py file, you can easily create one and save it to the
drive. CircuitPython looks for code.py and executes the code within the file
automatically when the board starts up or resets. Following a change to the contents
of CIRCUITPY, such as making a change to the code.py file, the board will reset, and
the code will be run. You do not need to manually run the code. This is what makes it
so easy to get started with your project and update your code!
Note that all changes to the contents of CIRCUITPY, such as saving a new file,
renaming a current file, or deleting an existing file will trigger a reset of the board.
1. Use an editor that writes out the file completely when you save it.
Check out the Recommended Editors page(https://adafru.it/Vue) for details on
different editing options.
If you are dragging a file from your host computer onto the CIRCUITPY drive, you
still need to do step 2. Eject or Sync (below) to make sure the file is completely
written.
2. Eject or Sync the Drive After Writing
If you are using one of our not-recommended-editors, not all is lost! You can still make
it work.
On Windows, you can Eject or Safe Remove the CIRCUITPY drive. It won't actually
eject, but it will force the operating system to save your file to disk. On Linux, use the
sync command in a terminal to force the write to disk.
You also need to do this if you use Windows Explorer or a Linux graphical file
manager to drag a file onto CIRCUITPY.
Oh No I Did Something Wrong and Now The CIRCUITPY
Drive Doesn't Show Up!!!
Don't worry! Corrupting the drive isn't the end of the world (or your board!). If this
happens, follow the steps found on the Troubleshooting(https://adafru.it/Den) page
of every board guide to get your board up and running again.
Back to Editing Code...
Now! Let's try editing the program you added to your board. Open your code.py file
into your editor. You'll make a simple change. Change the first 0.5 to 0.1 . The code
should look like this:
import board
import digitalio
import time
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
Each CircuitPython program you run needs to have a lot of information to work. The
reason CircuitPython is so simple to use is that most of that information is stored in
other files and works in the background. The files built into CircuitPython are called m
odules, and the files you load separately are called libraries. Modules are built into
CircuitPython. Libraries are stored on your CIRCUITPY drive in a folder called lib.
import board
import digitalio
import time
The import statements tells the board that you're going to use a particular library or
module in your code. In this example, you imported three modules: board ,
digitalio , and time . All three of these modules are built into CircuitPython, so no
separate library files are needed. That's one of the things that makes this an excellent
first example. You don't need anything extra to make it work!
These three modules each have a purpose. The first one, board , gives you access to
the hardware on your board. The second, digitalio , lets you access that hardware
as inputs/outputs.The third, time , let's you control the flow of your code in multiple
ways, including passing time by 'sleeping'.
Setting Up The LED
The next two lines setup the code to use the LED.
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
Your board knows the red LED as LED . So, you initialise that pin, and you set it to
output. You set led to equal the rest of that information so you don't have to type it
all out again later in our code.
Loop-de-loops
The third section starts with a while statement. while True: essentially means,
"forever do the following:". while True: creates a loop. Code will loop "while" the
condition is "true" (vs. false), and as True is never False, the code will loop forever.
All code that is indented under while True: is "inside" the loop.
First, you have led.value = True . This line tells the LED to turn on. On the next
line, you have time.sleep(0.5) . This line is telling CircuitPython to pause running
code for 0.5 seconds. Since this is between turning the led on and off, the led will be
on for 0.5 seconds.
The next two lines are similar. led.value = False tells the LED to turn off, and tim
e.sleep(0.5) tells CircuitPython to pause for another 0.5 seconds. This occurs
between turning the led off and back on so the LED will be off for 0.5 seconds too.
Then the loop will begin again, and continue to do so as long as the code is running!
So, when you changed the first 0.5 to 0.1 , you decreased the amount of time that
the code leaves the LED on. So it blinks on really quickly before turning off!
Great job! You've edited code in a CircuitPython program!
What Happens When My Code Finishes Running?
When your code finishes running, CircuitPython resets your microcontroller board to
prepare it for the next run of code. That means any set up you did earlier no longer
For example, try reducing the code snippet above by eliminating the loop entirely,
and replacing it with led.value = True . The LED will flash almost too quickly to
see, and turn off. This is because the code finishes running and resets the pin state,
and the LED is no longer receiving a signal.
To that end, most CircuitPython programs involve some kind of loop, infinite or
otherwise.
What if I Don't Have the Loop?
If you don't have the loop, the code will run to the end and exit. This can lead to some
unexpected behavior in simple programs like this since the "exit" also resets the state
of the hardware. This is a different behavior than running commands via REPL. So if
you are writing a simple program that doesn't seem to work, you may need to add a
loop to the end so the program doesn't exit.
The simplest loop would be:
while True:
pass
And remember - you can press CTRL+C to exit the loop.
See also the Behavior section in the docs(https://adafru.it/Bvz).
Connecting to the Serial Console
One of the staples of CircuitPython (and programming in general!) is something called
a "print statement". This is a line you include in your code that causes your code to
output text. A print statement in CircuitPython (and Python) looks like this:
print("Hello, world!")
This line in your code.py would result in:
Hello, world!
However, these print statements need somewhere to display. That's where the serial
The Traceback (most recent call last): is telling you the last thing your board
was doing before you saved your file. This is normal behavior and will happen every
time the board resets. This is really handy for troubleshooting. Let's introduce an error
so you can see how it is used.
Delete the e at the end of True from the line led.value = True so that it says le
d.value = Tru
import board
import digitalio
import time
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT
while True:
print("Hello back to you!")
led.value = Tru
time.sleep(1)
led.value =False
time.sleep(1)
Save your file. You will notice that your red LED will stop blinking, and you may have a
colored status LED blinking at you. This is because the code is no longer correct and
can no longer run properly. You need to fix it!
Usually when you run into errors, it's not because you introduced them on purpose.
You may have 200 lines of code, and have no idea where your error could be hiding.
This is where the serial console can help. Let's take a look!
The Traceback (most recent call last): is telling you that the last thing it was
able to run was line 10 in your code. The next line is your error: NameError: name
'Tru' is not defined . This error might not mean a lot to you, but combined with
knowing the issue is on line 10, it gives you a great place to start!
To use the REPL, you first need to be connected to the serial console. Once that
connection has been established, you'll want to press CTRL+C.
If there is code running, in this case code measuring distance, it will stop and you'll
see Press any key to enter the REPL. Use CTRL-D to reload. Follow those
instructions, and press any key on your keyboard.
The Traceback (most recent call last): is telling you the last thing your board
was doing before you pressed Ctrl + C and interrupted it. The KeyboardInterrupt
is you pressing CTRL+C. This information can be handy when troubleshooting, but for
now, don't worry about it. Just note that it is expected behavior.
If your code.py file is empty or does not contain a loop, it will show an empty output
and Code done running. . There is no information about what your board was
doing before you interrupted it because there is no code running.
If you have no code.py on your CIRCUITPY drive, you will enter the REPL immediately
after pressing CTRL+C. Again, there is no information about what your board was
doing before you interrupted it because there is no code running.
Regardless, once you press a key you'll see a >>> prompt welcoming you to the
REPL!
If you have trouble getting to the >>> prompt, try pressing Ctrl + C a few more times.
The first thing you get from the REPL is information about your board.
This line tells you the version of CircuitPython you're using and when it was released.
Next, it gives you the type of board you're using and the type of microcontroller the
board uses. Each part of this may be different for your board depending on the
versions you're working with.
This is followed by the CircuitPython prompt.
Interacting with the REPL
From this prompt you can run all sorts of commands and code. The first thing you'll do
is run help() . This will tell you where to start exploring the REPL. To run code in the
First part of the message is another reference to the version of CircuitPython you're
using. Second, a URL for the CircuitPython related project guides. Then... wait. What's
this? To list built-in modules type `help("modules")`. Remember the
modules you learned about while going through creating code? That's exactly what
this is talking about! This is a perfect place to start. Let's take a look!
Type help("modules") into the REPL next to the prompt, and press enter.
This is a list of all the core modules built into CircuitPython, including board .
Remember, board contains all of the pins on the board that you can use in your
code. From the REPL, you are able to see that list!
Type import board into the REPL and press enter. It'll go to a new prompt. It might
look like nothing happened, but that's not the case! If you recall, the import
statement simply tells the code to expect to do something with that module. In this
case, it's telling the REPL that you plan to do something with that module.
Next, type dir(board) into the REPL and press enter.
This is a list of all of the pins on your board that are available for you to use in your
code. Each board's list will differ slightly depending on the number of pins available.
Do you see LED ? That's the pin you used to blink the red LED!
an obvious place to start, and a relatively simple way to figure out the rest. First up:
the best place to start.
When you look at most CircuitPython examples, you'll see they begin with one or
more import statements. These typically look like the following:
import library_or_module
•
However, import statements can also sometimes look like the following:
from library_or_module import name
•
from library_or_module.subpackage import name
•
from library_or_module import name as local_name
•
They can also have more complicated formats, such as including a try / except
block, etc.
The important thing to know is that an import statement will always include the
name of the module or library that you're importing.
Therefore, the best place to start is by reading through the import statements.
Here is an example import list for you to work with in this section. There is no setup or
other code shown here, as the purpose of this section involves only the import list.
import time
import board
import neopixel
import adafruit_lis3dh
import usb_hid
from adafruit_hid.consumer_control import ConsumerControl
from adafruit_hid.consumer_control_code import ConsumerControlCode
Keep in mind, not all imported items are libraries. Some of them are almost always
built-in CircuitPython modules. How do you know the difference? Time to visit the
REPL.
In the Interacting with the REPL section(https://adafru.it/Awz) on The REPL page(http
s://adafru.it/Awz) in this guide, the help("modules") command is discussed. This
command provides a list of all of the built-in modules available in CircuitPython for
your board. So, if you connect to the serial console on your board, and enter the
REPL, you can run help("modules") to see what modules are available for your
board. Then, as you read through the import statements, you can, for the purposes
of figuring out which libraries to load, ignore the statement that import modules.
The following is the list of modules built into CircuitPython for the Feather RP2040.
Your list may look similar or be anything down to a significant subset of this list for
smaller boards.
Now that you know what you're looking for, it's time to read through the import
statements. The first two, time and board , are on the modules list above, so they're
built-in.
The next one, neopixel , is not on the module list. That means it's your first library!
So, you would head over to the bundle zip you downloaded, and search for neopixel.
There is a neopixel.mpy file in the bundle zip. Copy it over to the lib folder on your CI
RCUITPY drive. The following one, adafruit_lis3dh , is also not on the module list.
Follow the same process for adafruit_lis3dh, where you'll find adafruit_lis3dh.mpy,
and copy that over.
The fifth one is usb_hid , and it is in the modules list, so it is built in. Often all of the
built-in modules come first in the import list, but sometimes they don't! Don't assume
that everything after the first library is also a library, and verify each import with the
modules list to be sure. Otherwise, you'll search the bundle and come up empty!
The final two imports are not as clear. Remember, when import statements are
formatted like this, the first thing after the from is the library name. In this case, the
library name is adafruit_hid . A search of the bundle will find an adafruit_hid folder.
When a library is a folder, you must copy the entire folder and its contentsas it is in
the bundle to the lib folder on your CIRCUITPY drive. In this case, you would copy the
entire adafruit_hid folder to your CIRCUITPY/lib folder.
Notice that there are two imports that begin with adafruit_hid . Sometimes you will
need to import more than one thing from the same library. Regardless of how many
times you import the same library, you only need to load the library by copying over
the adafruit_hid folder once.
That is how you can use your example code to figure out what libraries to load on
your CircuitPython-compatible board!
There are cases, however, where libraries require other libraries internally. The
internally required library is called a dependency. In the event of library
dependencies, the easiest way to figure out what other libraries are required is to
connect to the serial console and follow along with the ImportError printed there.
The following is a very simple example of an ImportError , but the concept is the
same for any missing library.
Example: ImportError Due to Missing Library
If you choose to load libraries as you need them, or you're starting fresh with an
existing example, you may end up with code that tries to use a library you haven't yet
loaded. This section will demonstrate what happens when you try to utilise a library
that you don't have loaded on your board, and cover the steps required to resolve the
issue.
This demonstration will only return an error if you do not have the required library
loaded into the lib folder on your CIRCUITPY drive.
Let's use a modified version of the Blink example.
import board
import time
import simpleio
led = simpleio.DigitalOut(board.LED)
while True:
led.value = True
time.sleep(0.5)
led.value = False
time.sleep(0.5)
Save this file. Nothing happens to your board. Let's check the serial console to see
You have an ImportError . It says there is no module named 'simpleio' . That's
the one you just included in your code!
Click the link above to download the correct bundle. Extract the lib folder from the
downloaded bundle file. Scroll down to find simpleio.mpy. This is the library file you're
looking for! Follow the steps above to load an individual library file.
The LED starts blinking again! Let's check the serial console.
No errors! Excellent. You've successfully resolved an ImportError !
If you run into this error in the future, follow along with the steps above and choose
the library that matches the one you're missing.
Library Install on Non-Express Boards
If you have an M0 non-Express board such as Trinket M0, Gemma M0, QT Py M0, or
one of the M0 Trinkeys, you'll want to follow the same steps in the example above to
install libraries as you need them. Remember, you don't need to wait for an ImportEr
ror if you know what library you added to your code. Open the library bundle you
downloaded, find the library you need, and drag it to the lib folder on your CIRCUITPY
drive.
You can still end up running out of space on your M0 non-Express board even if you
only load libraries as you need them. There are a number of steps you can use to try
to resolve this issue. You'll find suggestions on the Troubleshooting page(https://
The main page covers the basics including where to download CircuitPython, how to
contribute, differences from MicroPython, information about the project structure, and
a full table of contents for the rest of the documentation.
The list along the left side leads to more information about specific topics.
The first section is API and Usage. This is where you can find information about how
to use individual built-in core modules, such as time and digitalio , details about
the supported ports, suggestions for troubleshooting, and basic info and links to the li
brary bundles. The Core Modules section also includes the Support Matrix, which is a
table of which core modules are available on which boards.
The second section is Design and Porting Reference. It includes a design guide, archit
ecture information, details onporting, and adding module support to other ports.
The third section is MicroPython Specific. It includes information on MicroPython and
related libraries, and a glossary of terms.
The fourth and final section is About the Project. It includes further information
including details on building, testing, and debugging CircuitPython, along with various
other useful links including the Adafruit Community Code of Conduct.
Whether you're a seasoned pro or new to electronics and programming, you'll find a
wealth of information to help you along your CircuitPython journey in the
When you click on an item in the API Reference section, you'll find details about the
classes and functions in the library. In the case of only one item in this section, all the
available functionality of the library will be contained within that first and only
subsection. However, in the case of a library that has subpackages, each item will
contain the features of the particular subpackage indicated by the link. The
documentation will cover all of the available functions of the library, including more
complex ones that may not interest you.
The first list item is the animation subpackage. If you scroll down, you'll begin to see
the available features of animation. They are listed alphabetically. Each of these
things can be called in your code. It includes the name and a description of the
specific function you would call, and if any parameters are necessary, lists those with
a description as well.
You can view the other subpackages by clicking the link on the left or scrolling down
the page. You may be interested in something a little more practical. Here is an
example. To use the LED Animation library Comet animation, you would run the
following example.
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
This example animates a jade comet that bounces from end to end of the strip.
For QT Py Haxpress and a NeoPixel strip. Update pixel_pin and pixel_num to match
your wiring if
using a different board or form of NeoPixels.
This example will run on SAMD21 (M0) Express boards (such as Circuit Playground
Express or QT Py
Haxpress), but not on SAMD21 non-Express boards (such as QT Py or Trinket).
"""
import board
import neopixel
from adafruit_led_animation.animation.comet import Comet
from adafruit_led_animation.color import JADE
Note the line where you create the comet object. There are a number of items inside
the parentheses. In this case, you're provided with a fully working example. But what
if you want to change how the comet works? The code alone does not explain what
the options mean.
So, in the API Reference documentation list, click the
adafruit_led_animation.animation.comet link and scroll down a bit until you
see the following.
Look familiar? It is! This is the documentation for setting up the comet object. It
explains what each argument provided in the comet setup in the code meant, as well
as the other available features. For example, the code includes speed=0.02 . The
documentation clarifies that this is the "Animation speed in seconds". The code
doesn't include ring . The documentation indicates this is an available setting that
enables "Ring mode".
This type of information is available for any function you would set up in your code. If
you need clarification on something, wonder whether there's more options available,
or are simply interested in the details involved in the code you're writing, check out
the documentation for the CircuitPython libraries!
IDLE(https://adafru.it/IWB), in Python 3.8.1 or later, was fixed(https://adafru.it/
•
IWD) to write all changes immediately
thonny(https://adafru.it/Qb6) fully writes files on save
•
Recommended only with particular settings or add-ons
vim(https://adafru.it/ek9)/visafely writes all changes. But set upvimto not
•
write swapfiles(https://adafru.it/ELO) (.swp files: temporary records of your edits)
to CIRCUITPY. Run vim with vim -n ,set the no swapfile option, or set the d
irectory option to write swapfiles elsewhere. Otherwise the swapfile
writestrigger restarts of your program.
ThePyCharm IDE(https://adafru.it/xNC)is safe if "Safe Write" is turned on in
•
Settings->System Settings->Synchronization (true by default).
If you are usingAtom(https://adafru.it/fMG), install thefsync-on-save package(h
•
ttps://adafru.it/E9m) or the language-circuitpython package(https://adafru.it/Vuf )
so that it will always write out all changes to files on CIRCUITPY.
SlickEdit(https://adafru.it/DdP)works only if youadd a macro to flush the disk(ht
•
tps://adafru.it/ven).
The editors listed below are specifically NOT recommended!
Editors that are NOT recommended
notepad (the default Windows editor) and Notepad++ can be slow to write, so
•
the editors above are recommended! If you are using notepad, be sure to eject
the drive
IDLE in Python 3.8.0 or earlier does not force out changes immediately
•
nano (on Linux) does not force out changes
•
geany (on Linux) does not force out changes
•
Anything else - Other editors have not been tested so please use a
If no code is running, the window will either be blank or will look like the window
above. Now you're ready to see the results of your code.
Great job! You've connected to the serial console!
Advanced Serial Console on Mac
Connecting to the serial console on Mac does not require installing any drivers or
extra software. You'll use a terminal program to find your board, and screen to
connect to it. Terminal and screen both come installed by default.
What's the Port?
First you'll want to find out which serial port your board is using. When you plug your
board in to USB on your computer, it connects to a serial port. The port is like a door
through which your board can communicate with your computer using USB.
The easiest way to determine which port the board is using is to first check without
the board plugged in. Open Terminal and type the following:
ls /dev/tty.*
Each serial connection shows up in the /dev/ directory. It has a name that starts with
tty. . The command ls shows you a list of items in a directory. You can use * as a
wildcard, to search for files that start with the same letters but end in something
different. In this case, you're asking to see all of the listings in /dev/ that start with t
ty. and end in anything. This will show us the current serial connections.
This will show you the current serial connections, which will now include your board.
A new listing has appeared called /dev/tty.usbmodem141441 . The tty.usbmodem1
41441 part of this listing is the name the example board is using. Yours will be called
something similar.
Using Linux, a new listing has appeared called /dev/ttyACM0 . The ttyACM0 part of
this listing is the name the example board is using. Yours will be called something
similar.
Connect with screen
Now that you know the name your board is using, you're ready connect to the serial
console. You're going to use a command called screen . The screen command is
included with MacOS. To connect to the serial console, use Terminal. Type the
following command, replacing board_name with the name you found your board is
using:
screen /dev/tty.board_name 115200
The first part of this establishes using the screen command. The second part tells
screen the name of the board you're trying to use. The third part tells screen what
baud rate to use for the serial connection. The baud rate is the speed in bits per
second that data is sent over the serial connection. In this case, the speed required
by the board is 115200 bits per second.
Press enter to run the command. It will open in the same window. If no code is
running, the window will be blank. Otherwise, you'll see the output of your code.
Great job! You've connected to the serial console!
Advanced Serial Console on Linux
Connecting to the serial console on Linux does not require installing any drivers, but
you may need to install screen using your package manager. You'll use a terminal
program to find your board, and screen to connect to it. There are a variety of
terminal programs such as gnome-terminal (called Terminal) or Konsole on KDE.
The tio program works as well to connect to your board, and has the benefit of
automatically reconnecting. You would need to install it using your package manager.
First you'll want to find out which serial port your board is using. When you plug your
board in to USB on your computer, it connects to a serial port. The port is like a door
through which your board can communicate with your computer using USB.
The easiest way to determine which port the board is using is to first check without
the board plugged in. Open your terminal program and type the following:
ls /dev/ttyACM*
Each serial connection shows up in the /dev/ directory. It has a name that starts with tt
yACM. The command ls shows you a list of items in a directory. You can use * as a
wildcard, to search for files that start with the same letters but end in something
different. In this case, You're asking to see all of the listings in /dev/ that start with ttyA
CM and end in anything. This will show us the current serial connections.
In the example below, the error is indicating that are no current serial connections
starting with ttyACM.
Now plug in your board. In your terminal program, type:
ls /dev/ttyACM*
This will show you the current serial connections, which will now include your board.
A new listing has appeared called /dev/ttyACM0. The ttyACM0 part of this listing is
the name the example board is using. Yours will be called something similar.
Connect with screen
Now that you know the name your board is using, you're ready connect to the serial
console. You'll use a command called screen . You may need to install it using the
package manager.
To connect to the serial console, use your terminal program. Type the following
command, replacing board_name with the name you found your board is using:
screen /dev/tty.board_name 115200
The first part of this establishes using the screen command. The second part tells
screen the name of the board you're trying to use. The third part tells screen what
baud rate to use for the serial connection. The baud rate is the speed in bits per
second that data is sent over the serial connection. In this case, the speed required
Press enter to run the command. It will open in the same window. If no code is
running, the window will be blank. Otherwise, you'll see the output of your code.
Great job! You've connected to the serial console!
Permissions on Linux
If you try to run screen and it doesn't work, then you may be running into an issue
with permissions. Linux keeps track of users and groups and what they are allowed to
do and not do, like access the hardware associated with the serial connection for
running screen . So if you see something like this:
then you may need to grant yourself access. There are generally two ways you can do
this. The first is to just run screen using the sudo command, which temporarily
gives you elevated privileges.
Once you enter your password, you should be in:
The second way is to add yourself to the group associated with the hardware. To
figure out what that group is, use the command ls -l as shown below. The group
Then use the command adduser to add yourself to that group. You need elevated
privileges to do this, so you'll need to use sudo . In the example below, the group is a
dm and the user is ackbar.
After you add yourself to the group, you'll need to logout and log back in, or in some
cases, reboot your machine. After you log in again, verify that you have been added
to the group using the command groups . If you are still not in the group, reboot and
check again.
And now you should be able to run screen without using sudo .
And you're in:
The examples above use screen , but you can also use other programs, such as put
about using AirLift with specific hardware, check out the Adafruit Learn
System(https://adafru.it/VBr).
Is there asyncio support in CircuitPython?
There is preliminary support for asyncio starting with CircuitPython 7.1.0. Read
about using it in the Cooperative Multitasking in CircuitPython(https://adafru.it/
XnA) Guide.
My RGB NeoPixel/DotStar LED is blinking funny colors what does it mean?
The status LED can tell you what's going on with your CircuitPython board. Read
more here for what the colors mean!(https://adafru.it/Den)
What is a MemoryError?
Memory allocation errors happen when you're trying to store too much on the
board. The CircuitPython microcontroller boards have a limited amount of memory
available. You can have about 250 lines of code on the M0 Express boards. If you
try to import too many libraries, a combination of large libraries, or run a program
with too many lines of code, your code will fail to run and you will receive a
MemoryError in the serial console.
What do I do when I encounter a MemoryError?
Try resetting your board. Each time you reset the board, it reallocates the memory.
While this is unlikely to resolve your issue, it's a simple step and is worth trying.
Make sure you are using .mpy versions of libraries. All of the CircuitPython libraries
are available in the bundle in a .mpy format which takes up less memory than .py
format. Be sure that you're using the latest library bundle(https://adafru.it/uap) for
your version of CircuitPython.
If that does not resolve your issue, try shortening your code. Shorten comments,
remove extraneous or unneeded code, or any other clean up you can do to
shorten your code. If you're using a lot of functions, you could try moving those
into a separate library, creating a .mpy of that library, and importing it into your
code.
You can turn your entire file into a .mpy and import that into code.py. This means
you will be unable to edit your code live on the board, but it can save you space.
Nobody likes bugs, but all nontrivial software and hardware has some. The master list
of problems is the Issues list on github(https://adafru.it/PEk).
Adafruit considers CircuitPython for the ESP32-S2 to be beta quality software.
I2C at 100 kHz bus frequency runs slowly
The default I2C bus clock speed is 100 kHz (100000) . At that rate, the ESP32-S2
will leave 10ms(https://adafru.it/ZCc) gaps between I2C transactions. This can slow
down your I2C interactions considerably, such as when you are controlling a
stepper motor with a PCA9685 controller.
Raising the I2C bus frequency to 125 kHz (125000) or higher fixes this problem. If
your I2C peripheral can handle higher frequencies, you can use 400 kHz (400000)
or even in some cases 1 MHz (1000000).
Note that board.I2C() creates an I2C bus that runs at 100 kHz. The bus
frequency cannot be changed.. To create an I2C bus on the default I2C pins that
runs at a different frequency, you must use busio.I2C(board.SCL, board.SDA,
frequency=) .
No DAC-based audio output
Current versions of the ESP-IDF SDK do not have the required APIs for DAC-based
audio output. Once a future version of ESP-IDF that adds it, it will be possible to
implement DAC-based AudioOut in CircuitPython.
Workaround: PWMOut can create tones and buzzes.
Workaround: I2SOut audio is currently being developed and will work with boards
such as the Adafruit I2S Stereo Decoder - UDA1334A Breakout(https://adafru.it/
As new versions of CircuitPython are released, Adafruit will stop providing the
previous bundles as automatically created downloads on the Adafruit CircuitPython
Library Bundle repo. If you must continue to use an earlier version, you can still
download the appropriate version of mpy-cross from the particular release of
CircuitPython on the CircuitPython repo and create your own compatible .mpy library
files. However, it is best to update to the latest for both CircuitPython and the library
bundle.
I have to continue using CircuitPython 5.x or earlier.
Where can I find compatible libraries?
Adafruit is no longer building or supporting the CircuitPython 5.x or earlier library
bundles. You are highly encourged to update CircuitPython to the latest version(https
://adafru.it/Em8) and use the current version of the libraries(https://adafru.it/ENC).
However, if for some reason you cannot update, links to the previous bundles are
available in the FAQ(https://adafru.it/FwY).
Bootloader (boardnameBOOT) Drive Not
Present
You may have a different board.
Only Adafruit Express boards and the SAMD21 non-Express boards ship with the UF2
bootloader (https://adafru.it/zbX)installed. The Feather M0 Basic, Feather M0
Adalogger, and similar boards use a regular Arduino-compatible bootloader, which
does not show a boardnameBOOT drive.
MakeCode
If you are running a MakeCode(https://adafru.it/zbY) program on Circuit Playground
Express, press the reset button just onceto get the CPLAYBOOT drive to show up.
Pressing it twice will not work.
MacOS
DriveDx and its accompanything SAT SMART Driver can interfere with seeing the
BOOT drive. See this forum post(https://adafru.it/sTc) for how to fix the problem.
If not, try cleaning up your USB devices. Use Uwe Sieber's Device Cleanup Tool(https
://adafru.it/RWd). Download and unzip the tool. Unplug all the boards and other USB
devices you want to clean up. Run the tool as Administrator. You will see a listing like
this, probably with many more devices. It is listing all the USB devices that are not
currently attached.
Select all the devices you want to remove, and then press Delete. It is usually safe
just to select everything. Any device that is removed will get a fresh install when you
plug it in. Using the Device Cleanup Tool also discards all the COM port assignments
for the unplugged boards. If you have used many Arduino and CircuitPython boards,
you have probably seen higher and higher COM port numbers used, seemingly
without end. This will fix that problem.
Serial Console in Mu Not Displaying
Anything
There are times when the serial console will accurately not display anything, such as,
when no code is currently running, or when code with no serial output is already
running before you open the console. However, if you find yourself in a situation
where you feel it should be displaying something like an error, consider the following.
Depending on the size of your screen or Mu window, when you open the serial
console, the serial console panel may be very small. This can be a problem. A basic
CircuitPython error takes 10 lines to display!
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Traceback (most recent call last):
File "code.py", line 7
Press any key to enter the REPL. Use CTRL-D to reload.
More complex errors take even more lines!
Therefore, if your serial console panel is five lines tall or less, you may only see blank
lines or blank lines followed by Press any key to enter the REPL. Use CTRL-D
to reload. . If this is the case, you need to either mouse over the top of the panel to
utilise the option to resize the serial panel, or use the scrollbar on the right side to
scroll up and find your message.
This applies to any kind of serial output whether it be error messages or print
statements. So before you start trying to debug your problem on the hardware side,
be sure to check that you haven't simply missed the serial messages due to serial
output panel height.
code.py Restarts Constantly
CircuitPython will restart code.py if you or your computer writes to something on the
CIRCUITPY drive. This feature is called auto-reload, and lets you test a change to your
program immediately.
Some utility programs, such as backup, anti-virus, or disk-checking apps, will write to
the CIRCUITPY as part of their operation. Sometimes they do this very frequently,
causing constant restarts.
Acronis True Image and related Acronis programs on Windows are known to cause
this problem. It is possible to prevent this by disabling the "(https://adafru.it/XDZ)Acro
nis Managed Machine Service Mini"(https://adafru.it/XDZ).
If you cannot stop whatever is causing the writes, you can disable auto-reload by
and CYAN are one's place. So for example, an error on line 32 would flash YELLOW
three times and then CYAN two times. Zeroes are indicated by an extra-long dark gap.
Serial console showing ValueError:
Incompatible .mpy file
This error occurs when importing a module that is stored as a .mpy binary file that
was generated by a different version of CircuitPython than the one its being loaded
into. In particular, the mpy binary format changed between CircuitPython versions 6.x
and 7.x, 2.x and 3.x, and 1.x and 2.x.
So, for instance, if you upgraded to CircuitPython 7.x from 6.x you’ll need to download
a newer version of the library that triggered the error on import . All libraries are
available in the Adafruit bundle(https://adafru.it/y8E).
CIRCUITPY Drive Issues
You may find that you can no longer save files to your CIRCUITPY drive. You may find
that your CIRCUITPY stops showing up in your file explorer, or shows up as NO_NAM
E. These are indicators that your filesystem has issues. When the CIRCUITPY disk is
not safely ejected before being reset by the button or being disconnected from USB,
it may corrupt the flash drive. It can happen on Windows, Mac or Linux, though it is
If you are copying to the lib folder, or another folder, make sure it exists before
copying.
#if lib does not exist, you'll create a file named lib !
cp -X file_name.mpy /Volumes/CIRCUITPY/lib
#This is safer, and will complain if a lib folder does not exist.
cp -X file_name.mpy /Volumes/CIRCUITPY/lib/
Other MacOS Space-Saving Tips
If you'd like to see the amount of space used on the drive and manually delete hidden
files here's how to do so. First, move into the Volumes/ directory with cd /Volumes/ ,
and then list the amount of space used on the CIRCUITPY drive with the df
command.
That's not very much space left! The next step is to show a list of the files currently on
the CIRCUITPY drive, including the hidden files, using the ls command. You cannot
use Finder to do this, you must do it via command line!
There are a few of the hidden files that MacOS loves to generate, all of which begin
with a ._ before the file name. Remove the ._ files using the rm command. You can
remove them all once by running rm CIRCUITPY/._* . The * acts as a wildcard to
apply the command to everything that begins with ._ at the same time.
Finally, you can run df again to see the current space used.