It's easy to use the NeoDriver with Python or CircuitPython, and the Adafruit_CircuitPython_seesaw module. This module allows you to easily write Python code that controls NeoPixels over I2C.
You can use this adapter with any CircuitPython microcontroller board or with a computer that has GPIO and Python thanks to Adafruit_Blinka, our CircuitPython-for-Python compatibility library.
CircuitPython Microcontroller Wiring
First wire up a NeoDriver to your board exactly as follows. The following is the NeoDriver wired to a Feather RP2040 using the STEMMA connector:
- Board STEMMA 3V to driver VIN (red wire)
- Board STEMMA GND to driver GND (black wire)
- Board STEMMA SCL to driver SCL (yellow wire)
- Board STEMMA SDA to driver SDA (blue wire)
- 5V power supply positive to driver 5Vin (red wire)
- 5V power supply ground to driver G (black wire)
- NeoPixel power to driver 5Vo (red wire)
- NeoPixel data to driver Neo (green wire)
- NeoPixel ground to driver G (black wire)
The following is the NeoDriver wired to a Feather RP2040 using a solderless breadboard:
- Board 3V to driver VIN (red wire)
- Board GND to driver GND (black wire)
- Board SCL to driver SCL (yellow wire)
- Board SDA to driver SDA (blue wire)
- 5V power supply positive to driver 5Vin (red wire)
- 5V power supply ground to driver G (black wire)
- NeoPixel power to driver 5Vo (red wire)
- NeoPixel data to driver Neo (green wire)
- NeoPixel ground to driver G (black wire)
Python Computer Wiring
Since there's dozens of Linux computers/boards you can use we will show wiring for Raspberry Pi. For other platforms, please visit the guide for CircuitPython on Linux to see whether your platform is supported.
Here's the Raspberry Pi wired with I2C using the STEMMA connector:
- Pi 3V to adapter VIN (red wire)
- Pi GND to adapter GND (black wire)
- Pi SCL to adapter SCL (yellow wire)
- Pi SDA to adapter SDA (blue wire)
- 5V power supply positive to driver 5Vin (red wire)
- 5V power supply ground to driver G (black wire)
- NeoPixel power to driver 5Vo (red wire)
- NeoPixel data to driver Neo (green wire)
- NeoPixel ground to driver G (black wire)
Here's the Raspberry Pi wired with I2C using a solderless breadboard:
- Pi 3V to adapter VIN (red wire)
- Pi GND to adapter GND (black wire)
- Pi SCL to adapter SCL (yellow wire)
- Pi SDA to adapter SDA (blue wire)
- 5V power supply positive to driver 5Vin (red wire)
- 5V power supply ground to driver G (black wire)
- NeoPixel power to driver 5Vo (red wire)
- NeoPixel data to driver Neo (green wire)
- NeoPixel ground to driver G (black wire)
Python Installation of seesaw Library
You'll need to install the Adafruit_Blinka library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3. Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready!
Once that's done, from your command line run the following command:
pip3 install adafruit-circuitpython-seesaw
If your default Python is version 3 you may need to run 'pip' instead. Just make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!
CircuitPython Usage
To use with CircuitPython, you need to first install the Adafruit_CircuitPython_seesaw library, and its dependencies, into the lib folder on your CIRCUITPY drive. Then you need to update code.py with the example script.
Thankfully, we can do this in one go. In the example below, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, and copy the entire lib folder and the code.py file to your CIRCUITPY drive.
Your CIRCUITPY/lib folder should contain the following folders and file:
- adafruit_bus_device/
- adafruit_seesaw/
- adafruit_pixelbuf.mpy
Python Usage
Once you have the library pip3
installed on your computer, copy or download the following example to your computer, and run the following, replacing code.py with whatever you named the file:
python3 code.py
Simple Test Example Code
If running CircuitPython: Once everything is saved to the CIRCUITPY drive, connect to the serial console to see the data printed out!
If running Python: The console output will appear wherever you are running Python.
# SPDX-FileCopyrightText: 2023 Liz Clark for Adafruit Industries # SPDX-License-Identifier: MIT import time import board import busio from rainbowio import colorwheel from adafruit_seesaw import seesaw, neopixel i2c = busio.I2C(board.SCL, board.SDA) ss = seesaw.Seesaw(i2c, addr=0x60) neo_pin = 15 num_pixels = 64 pixels = neopixel.NeoPixel(ss, neo_pin, num_pixels, brightness = 0.1) color_offset = 0 while True: for i in range(num_pixels): rc_index = (i * 256 // num_pixels) + color_offset pixels[i] = colorwheel(rc_index & 255) pixels.show() color_offset += 1 time.sleep(0.01)
In the simple test example, the code instantiates the board over I2C and creates a NeoPixel
object. In the loop, the connected NeoPixels advance through a rainbow color gradient.
Considerations for Other Single Board Computers
We often get folks asking how to get NeoPixels working on some OrangeBananaOnionRockchipAllWinner Pi type board and this breakout helps in solving that problem by sending the NeoPixel data over I2C.
All single board computers are different though and come with their own unique set of quirks. Here are some tips and tricks for trying out when using this breakout with your OrangeBananaOnionRockchipAllWinner Pi type board.
Enable and Scan I2C
It may seem obvious, but making sure that the I2C bus is enabled properly on your board and is seeing the NeoDriver I2C address can vary from board to board. Some may have their own tool for doing this (similar to raspi-config
on a Raspberry Pi), while others may expect you to do it via the terminal. You may need to enable a device tree overlay (dtoverlay
) as well. Check your board manufacturer's wiki pages and support forums for the recommended technique. You can check which I2C buses are enabled on your board in the terminal:
ls /dev/i2c*
Once you have I2C enabled, you can connect the NeoDriver to the board's GPIO pins as described in the Raspberry Pi Fritzing diagrams earlier on this page and perform an I2C scan in the terminal:
sudo i2cdetect -r -y BUSNUMBER
where BUSNUMBER
is the expected I2C bus number (0
, 1
, 2
, etc).
This will check to see if your board is recognizing the NeoDriver and to see which I2C bus it is connected to. If your board has a Raspberry Pi-compatible GPIO header, then I2C-1 will usually be located on pins 3 and 5 and I2C-0 will usually be located on pins 27 and 28.
Adafruit Extended Bus Library
The go-to way to instantiate I2C in Blinka is to use the busio module. However, if you find that your board's GPIO I2C buses are not being recognized with your Python code despite the device showing up in an I2C scan, you may want to switch to the Adafruit_Extended_Bus helper library.
The Extended Bus helper library allows the creation of I2C and SPI busio objects by passing in the Bus ID. This library is not compatible with CircuitPython and is intended to only be run on Linux devices. You can install it in the terminal with pip
:
pip3 install adafruit-extended-bus
Here is example Python code for the NeoDriver using the Extended Bus library:
# SPDX-FileCopyrightText: 2023 Liz Clark for Adafruit Industries # SPDX-License-Identifier: MIT '''This example should only be used with Linux single board computers that require creating an I2C busio object by passing in the Bus ID''' import time from rainbowio import colorwheel from adafruit_extended_bus import ExtendedI2C as I2C from adafruit_seesaw import seesaw, neopixel i2c = I2C(1, frequency=800000) ss = seesaw.Seesaw(i2c, addr=0x60) neo_pin = 15 num_pixels = 30 pixels = neopixel.NeoPixel(ss, neo_pin, num_pixels, brightness = 0.3, auto_write=False) color_offset = 0 while True: for i in range(num_pixels): rc_index = (i * 256 // num_pixels) + color_offset pixels[i] = colorwheel(rc_index & 255) pixels.show() color_offset += 8 time.sleep(0.01)
Text editor powered by tinymce.