223 lines
10 KiB

.. image::
|Build Status| |Doc Status| |License| |Discord|
` <>`__ \| `Get CircuitPython <#get-circuitpython>`__ \|
`Documentation <#documentation>`__ \| `Contributing <#contributing>`__ \|
`Branding <#branding>`__ \| `Differences from Micropython <#differences-from-micropython>`__ \|
`Project Structure <#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 board via drag and drop and then edit a ```` file on
the CIRCUITPY drive. The code will automatically reload. No software installs are needed besides a
text editor (we recommend `Mu <>`_ for beginners.)
CircuitPython features unified Python core APIs and a growing list of 150+ 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 <#differences-from-micropython>`_ for differences. CircuitPython development is sponsored by
`Adafruit <>`_ and is available on their educational development boards. Please
support both MicroPython and Adafruit.
Get CircuitPython
Official binaries for all supported boards are available through
` <>`_. The site includes stable, unstable and
continuous builds. Full release notes and assets 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:
- `Welcome to CircuitPython <>`__
- `CircuitPython Essentials <>`__
- `Example Code <>`__
` <>`__
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:
* Your product is supported by the primary
`"adafruit/circuitpython" <>`_ repo. This way we can
update any custom code as we update the CircuitPython internals.
* Your product is listed on ` <>`__ (source
`here <>`_). This is to ensure that a user of your
product can always download the latest version of CircuitPython from the standard place.
* Your product has a user accessible USB plug which appears as a CIRCUITPY drive when plugged in.
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.
Differences from `MicroPython <>`__
- includes ports for MicroChip SAMD21 (Commonly known as M0 in Adafruit
product names) and SAMD51 (M4).
- supports only SAMD21, SAMD51, and nRF52840 ports.
- tracks MicroPython's releases (not master).
- floats (aka decimals) are enabled for all builds.
- error messages are translated into 10+ languages.
- does not support concurrency within Python (including interrupts and threading). Some concurrency
is achieved with native modules for tasks that require it such as audio file playback.
- The order that files are run and the state that is shared between
them. CircuitPython's goal is to clarify the role of each file and
make each file independent from each other.
- ```` (or ````) runs only once on start up before
USB is 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``.
- ```` (or ````) 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**
```` **in the REPL anymore.** CircuitPython's goal for this
change includes reduce confusion about pins and memory being used.
- After ```` the REPL can be entered by pressing any key. It no
longer shares state with ```` so it is a fresh vm.
- Autoreload state will be maintained across reload.
- Adds a safe mode that does not run user code after a hard crash or
brown out. The hope is that this will make it easier to fix code that
causes nasty crashes by making it available through mass storage
after the crash. A reset (the button) is needed after its fixed to
get back into normal mode.
- RGB status LED indicating CircuitPython state, and errors through a sequence of colored flashes.
- Re-runs ```` or other main file after file system writes over USB mass storage. (Disable with
- Entering the REPL after the main code is finished requires a key press which enters the REPL and
disables autoreload.
- Main is one of these: ``code.txt``, ````, ````,
- Boot is one of these: ``settings.txt``, ````, ````,
- Unified hardware APIs. Documented
`on ReadTheDocs <>`_.
- API docs are rST within the C files in ``shared-bindings``.
- No ``machine`` API.
- No module aliasing. (``uos`` and ``utime`` are not available as
``os`` and ``time`` respectively.) Instead ``os``, ``time``, and
``random`` are CPython compatible.
- New ``storage`` module which manages file system mounts.
(Functionality from ``uos`` in MicroPython.)
- Modules with a CPython counterpart, such as ``time``, ``os`` and
``random``, are strict
`subsets <>`__
of their `CPython
version <>`__.
Therefore, code from CircuitPython is runnable on CPython but not
necessarily the reverse.
- tick count is available as
`time.monotonic() <>`__
Project Structure
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
- ``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
- ``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 module.
Ports include the code unique to a microcontroller line and also
variations based on the board.
- ``atmel-samd`` Support for SAMD21 and SAMD51 based boards.
- ``nrf`` Support for the nRF52840 based boards.
- ``unix`` Support for UNIX. Only used for automated testing.
The remaining port directories not listed above are in the repo to maintain compatibility with the
`MicroPython <>`__ parent project.
`back to top <#circuitpython>`__
.. |Build Status| image::
.. |Doc Status| image::
.. |Discord| image::
.. |License| image::