circuitpython.org | Get CircuitPython | Documentation | Contributing | Branding | Differences from Micropython | Project Structure
CircuitPython is a beginner friendly, open source version of Python for tiny, inexpensive computers called microcontrollers. Microcontrollers are the brains of many electronics including a wide variety of development boards used to build hobby projects and prototypes. CircuitPython in electronics is one of the best ways to learn to code because it connects code to reality. Simply install CircuitPython on a supported USB board usually via drag and drop and then edit a code.py
file on the CIRCUITPY drive. The code will automatically reload. No software installs are needed besides a text editor (we recommend Mu for beginners.)
Starting with CircuitPython 7.0.0, some boards may only be connectable over Bluetooth Low Energy (BLE). Those boards provide serial and file access over BLE instead of USB using open protocols. (Some boards may use both USB and BLE.) BLE access can be done from a variety of apps including code.circuitpython.org.
CircuitPython features unified Python core APIs and a growing list of 300+ device libraries and drivers that work with it. These libraries also work on single board computers with regular Python via the Adafruit Blinka Library.
CircuitPython is based on MicroPython. See below for differences. Most, but not all, CircuitPython development is sponsored by Adafruit and is available on their educational development boards. Please support both MicroPython and Adafruit.
Official binaries for all supported boards are available through circuitpython.org/downloads. The site includes stable, unstable and continuous builds. Full release notes are available through GitHub releases as well.
Guides and videos are available through the Adafruit Learning System under the CircuitPython category. An API reference is also available on Read the Docs. A collection of awesome resources can be found at Awesome CircuitPython.
Specifically useful documentation when starting out:
See CONTRIBUTING.md for full guidelines but please be aware that by contributing to this project you are agreeing to the Code of Conduct. Contributors who follow the Code of Conduct are welcome to submit pull requests and they will be promptly reviewed by project admins. Please join the Discord too.
While we are happy to see CircuitPython forked and modified, we'd appreciate it if forked releases not use the name "CircuitPython" or the Blinka logo. "CircuitPython" means something special to us and those who learn about it. As a result, we'd like to make sure products referring to it meet a common set of requirements.
If you'd like to use the term "CircuitPython" and Blinka for your product here is what we ask:
If you choose not to meet these requirements, then we ask you call your version of CircuitPython something else (for example, SuperDuperPython) and not use the Blinka logo. You can say it is "CircuitPython-compatible" if most CircuitPython drivers will work with it.
CircuitPython:
boot.py
runs only once on start up before workflows are initialized. This lays the ground work for configuring USB at startup rather than it being fixed. Since serial is not available, output is written to boot_out.txt
.code.py
(or main.py
) is run after every reload until it finishes or is interrupted. After it is done running, the vm and hardware is reinitialized. This means you cannot read state from code.py
in the REPL anymore, as the REPL is a fresh vm. CircuitPython's goal for this change includes reducing confusion about pins and memory being used.repl.py
exists, it is executed before the REPL Prompt is shown - In safe mode this functionality is disabled, to ensure the REPL Prompt can always be reachedCIRCUITPY_SKIP_SAFE_MODE_WAIT
).safemode.py
. safemode.py
is run if the board has reset due to entering safe mode, unless the safe mode initiated by the user by pressing button(s). USB is not available so nothing can be printed. safemode.py
can determine why the safe mode occurred using supervisor.runtime.safe_mode_reason
, and take appropriate action. For instance, if a hard crash occurred, safemode.py
may do a microcontroller.reset()
to automatically restart despite the crash. If the battery is low, but is being charged, safemode.py
may put the board in deep sleep for a while. Or it may simply reset, and have code.py
check the voltage and do the sleep.code.py
or other main file after file system writes by a workflow. (Disable with supervisor.disable_autoreload()
)code.py
may also be named code.txt
, main.py
, or main.txt
.boot.py
may also be named boot.txt
.safemode.py
may also be named safemode.txt
.shared-bindings
.machine
API.uos
and utime
are not available as os
and time
respectively.) Instead os
, time
, and random
are CPython compatible.storage
module which manages file system mounts. (Functionality from uos
in MicroPython.)time
, os
and random
, are strict subsets of their CPython version. Therefore, code from CircuitPython is runnable on CPython but not necessarily the reverse.Here is an overview of the top-level source code directories.
The core code of MicroPython is shared amongst ports including CircuitPython:
docs
High level user documentation in Sphinx reStructuredText format.drivers
External device drivers written in Python.examples
A few example Python scripts.extmod
Shared C code used in multiple ports' modules.lib
Shared core C code including externally developed libraries such as FATFS.logo
The CircuitPython logo.mpy-cross
A cross compiler that converts Python files to byte code prior to being run in MicroPython. Useful for reducing library size.py
Core Python implementation, including compiler, runtime, and core library.shared-bindings
Shared definition of Python modules, their docs and backing C APIs. Ports must implement the C API to support the corresponding module.shared-module
Shared implementation of Python modules that may be based on common-hal
.tests
Test framework and test scripts.tools
Various tools, including the pyboard.py module.Ports include the code unique to a microcontroller line.
The following ports are available: atmel-samd
, cxd56
, espressif
, litex
, mimxrt10xx
, nordic
, raspberrypi
, renode
, silabs
(efr32
), stm
, unix
.
However, not all ports are fully functional. Some have limited functionality and known serious bugs. For details, refer to the Port status section in the latest release notes.
port
has a boards
directory containing boards which belong to a specific microcontroller line.RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4