Circuit Python at Noisebridge
Circuit Python at Noisebridge
Welcome to this page, which will get you started with Circuit Python. You can do this any time, or with a group at Circuit Hacking Monday
Some links to get started:
- If you are new to Circuit Python, start here! https://learn.adafruit.com/welcome-to-circuitpython/
- We are using the Lolin S2 Mini board. Here's some information: https://circuitpython.org/board/lolin_s2_mini/
Getting Started with Programming
- Try something simple. Can you make the onboard LED (board.LED) blink from the button (board.IO0)? https://learn.adafruit.com/circuitpython-essentials/circuitpython-digital-in-out
- Can you change the brightness of the LED using PWM? https://learn.adafruit.com/circuitpython-essentials/circuitpython-pwm
- Try something more complicated, like controlling Neopixel addressable LEDs: https://learn.adafruit.com/circuitpython-essentials/circuitpython-neopixel
- Your board can look like a USB HID device, so you can make it into a keyboard! https://learn.adafruit.com/make-it-a-keyboard/circuitpython
- Your board is Wi-Fi and Bluetooth capable! Try running a webserver, or connecting to your phone!
Hooking up Hardware
We have soldering equipment so you can install the headers that came with your board. A good tip is to put the headers into a solderless breadboard before soldering so they are straight and even. Only install the outside headers if you want to use this in a solderless breadboard otherwise they will short! We have lots of hardware to play with including sensors and Neopixel LEDs; you will need the Adafruit library: https://learn.adafruit.com/circuitpython-essentials/circuitpython-neopixel
Tips and Tricks
To see the names of the pins available, enter the REPL (using Mu or a terminal program
import board dir(board)
- For the LED library, pin 1 = IO1 and so forth... If you have installed only the outside headers, use pin IO3 (or odd numbered pins) so that there's something to connect to.
- It is possible that the silkscreen labels for pins 12 and 13 have been swapped. Test to make sure!
- Todbot has some fun code to play with, like synthesizers! https://gist.github.com/todbot/
Lolin S2 Mini pinout
board.A0 board.IO3 board.BUTTON board.IO0 board.D0 board.IO5 board.D1 board.IO35 board.SCL board.D2 board.IO33 board.SDA board.D3 board.IO18 board.D4 board.IO16 board.D5 board.IO7 board.SCK board.D6 board.IO9 board.MISO board.D7 board.IO11 board.MOSI board.D8 board.IO13 board.IO1 board.IO10 board.IO12 board.IO14 board.IO15 board.LED board.IO17 board.IO2 board.IO21 board.IO34 board.IO36 board.IO37 board.IO38 board.IO39 board.IO4 board.IO40 board.IO6 board.IO8
Installing Circuit Python on Lolin S2 Mini boards
We have already done this for you! But you might need to do it again, or if you get your own boards, this is how we do it.
- Download the latest Circuit Python binary from here: https://circuitpython.org/board/lolin_s2_mini/
- Put the Lolin S2 board into tty mode: while holding down the "0" button, press and release the "RESET" button. Make sure there's a tty (com port) available.
- Install esptool.py frop PIP: python -m pip install esptool
- At the command line, enter
esptool.py -p /dev/ttyACM0 --chip esp32s2 --baud 1000000 write_flash -z 0x0 adafruit-circuitpython-lolin_s2_mini-en_US-8.0.0-beta.6.bin(use the right serial port if not ttyACM0, also use filename of the binary you just downloaded: it will be more recent than 8.0.0)
- (if this doesn't work at first, try erasing flash with esptool.py --port PORT_NAME erase_flash, and/or repeat until it enumerates as /dev/ttyACM1)
- You can also do the previous 2 steps using https://adafruit.github.io/Adafruit_WebSerial_ESPTool/ or https://espressif.github.io/esptool-js/ but only on Chrome browsers. This can fix problems if esptool is not working.
- Reconnect your S2 Mini board, you should see a removable drive appear labeled CIRCUITPY
- You are now able to edit code.py, add libraries to /lib, and connect to the serial port (usually /dev/ttyACM0 on Mac/Linux or COM3 on Windows