Posts: 2
Joined: Mon Oct 15, 2018 8:25 am

Connecting two independant APA102 SPI Led strips

Mon Oct 15, 2018 10:12 am

Hi Guys,

I'm trying to connect 2 APA102 LED strips to my Pi3 b+. Each stript contains 2 RGB leds in order to do a simple POC without external power source. My goal is to drive the 2 strips independent of each other

So far, i got a single strip working by connecting by connecting SPI0 MOSI to led strip DI, and SPI0 SCLK to led strip CI. schema:

I'm able to control the leds on this strip through NodeJS, relevant code snippet:

Code: Select all

// node js libs
var Apa102spi = require('apa102-spi');
var rpio = require('rpio');
// number of leds, clock divider
this.LedDriver = new Apa102spi(2, 100);

// set led: index, brightness, r g b
this.LedDriver.setLedColor(0, 10, 0, 0, 255);
// write to strip

Now i want to connect a second strip, and drive it through SPI1 MOSI and SPI1 SCLK like so:

The assumption is that this way, I can control both strips independantly from the Pi by selecting output channel (SPI0 MOSI or SPI1 MOSI), e.g. (pseudo code):

Code: Select all

// number of leds, clock divider, data pin
this.LedDriver1 = new Apa102spi(2, 100, SPI0_MOSI);
this.LedDriver2 = new Apa102spi(2, 100, SPI1_MOSI);
this.LedDriver1.setLedColor(0, 10, 0, 0, 255);
this.LedDriver2.setLedColor(0, 10, 255, 0, 0);

I cant seem to get this working. I'm new to the raspberry Pi/GPIO, and i can't find any example of connecting two SPI led strips this way. I have the following questions:

1. Is the second schema/wiring example setup correct?
2. Are there any examples or tutorials for connecting 2 strips this way? Programming language is not important; Node JS would be ideal, but I should be able to figure it out if it's another language.
3. Any reading materials/links/information is welcome!

This is my first Raspberry project and my first message on this forum, so please forgive me my n00bischness ;)


Ufo guy

Posts: 2
Joined: Mon Oct 15, 2018 8:25 am

Re: Connecting two independant APA102 SPI Led strips

Tue Oct 16, 2018 10:46 am

1. Enable both spi0 and spi1 on the rasp ('dtoverlay=spi1-3cs' in /boot/config.txt)
2. Use another lib from the adafruit dotstar leds (apa102) https://www.npmjs.com/package/dotstar

Code: Select all

import * as dotstar from './dotstar';
const SPI = require('pi-spi');

spi0 = SPI.initialize('/dev/spidev0.0');
spi1 = SPI.initialize('/dev/spidev1.0');
const ledStripLength = 2;

const ledStrip1 = new dotstar.Dotstar(spi1, {
  length: ledStripLength

const ledStrip2= new dotstar.Dotstar(spi2, {
  length: ledStripLength

ledStrip1.all(255, 200, 175, 0.8);
ledStrip2.all(255, 200, 175, 0.8);

Return to “Interfacing (DSI, CSI, I2C, etc.)”