Friday, April 12, 2024

Circuit Python on the Lolin S2 Mini

ALT TEXT PLACEHOLDER

Circuit P

Welcome to this page, which will get you started with Circuit Python.

Some links to get started:

Getting Started with Programming

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.

  1. Download the latest Circuit Python binary from here: https://circuitpython.org/board/lolin_s2_mini/
  2. 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.
  3. Install esptool.py frop PIP: python -m pip install esptool
  4. 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)

  5. (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)
  6. 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.
  7. Reconnect your S2 Mini board, you should see a removable drive appear labeled CIRCUITPY
  8. 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
ALT TEXT PLACEHOLDER


Archives:


Topics:


RSSicon.png  RSS feed