Skip to content

circuitpython

"The easiest way to program microcontrollers. CircuitPython is a programming language designed to simplify experimenting and learning to code on low-cost microcontroller boards. " - https://circuitpython.org

Examples

Disable CIRCUITPYTHON usb drive

Create a boot.py file in the drive with the following contents:

import storage

storage.disable_usb_drive()

To re-enable the drive, use the serial console to access the repl and comment out all of the contents of boot.py by running:

import storage

with open('boot.py', mode='r') as f:
    contents = [f'#{x}' for x in f.readlines()]

with open('boot.py', mode='w') as f:
    f.write(''.join(contents))

or just delete the boot.py file with:

import os, storage
storage.remount('/', readonly=False)
os.remove('/boot.py')

Paste mode

You can enter paste mode by pressing CTRL-E. This lets you paste in multi-line code that will not be interpreted until you press CTRL-D. This also lets you paste code that has spaces init without the REPL saying your syntax is invalid due to indentation problems or other whitespace nuances of the normal REPL.

See also