4
\$\begingroup\$

I have two chips that have the I2C (SDA / CLK) address clearly written in the data sheet.

Can I can drive this APA102 LED with the same SDA / CLK lines as other I2C chips?

What is the I2C address of the APA102? The datasheet doesn't have it, and all the examples use the FastLED library to drive the LEDs.

\$\endgroup\$
3
  • \$\begingroup\$ Please provide links to datasheets. Do you mean the APA102C? \$\endgroup\$
    – JYelton
    Jul 21, 2023 at 15:59
  • \$\begingroup\$ Are you sure you mean APA102? Those are not i2c. \$\endgroup\$ Jul 21, 2023 at 18:11
  • \$\begingroup\$ Thanks @user1850479 this is the answer to my problems. \$\endgroup\$
    – legoblocks
    Jul 22, 2023 at 10:32

2 Answers 2

4
\$\begingroup\$

The APA102C isn't "addressable" in the I2C sense. Rather, it is addressable based on its position in a serially-connected array of LEDs. (This is similar to WS2812-based LEDs, but the APA102C has a data and clock line while the WS2812 has only a single data line and uses different widths to differentiate 1 and 0.) They receive data more like SPI, without addressing (but also without chip select (CS)).

The horribly-formatted datasheet has this section:

APA102C datasheet excerpt

This appears to show that 32 bits are read by each LED, processed, and additional 32-bit "LED frames" are passed onto subsequent LEDs.

There is an excellent write-up on driving these by Tim aka cpldcpu, which I discovered via another article by Ethan Zonca at Hackaday. Additionally, there's an earlier article by Tim which is more of an introduction.

The summary or conclusion is that there are some interesting pros and cons with the APA102 protocol. Tim concludes by explaining the structure of each update of the LED string as follows:

  1. A start frame of 32 bits set to 0
  2. A 32-bit frame for each LED in the string
  3. An end frame with a minimum number of bits set to 1 depending on the number of LEDs in the string.

(I'm attempting not to plagiarize, but replicating the information here in case of link rot.)

For more information, definitely check out the links I included.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks JYelton. Great detailed response. \$\endgroup\$
    – legoblocks
    Jul 22, 2023 at 10:33
2
\$\begingroup\$

The answer is that the APA102 LEDs are not I2C. They are more like SPI

Thanks for your responses everyone.

\$\endgroup\$
5
  • \$\begingroup\$ There are libraries for driving those LEDs using the esp32, so yes it is possible. \$\endgroup\$ Jul 22, 2023 at 13:41
  • \$\begingroup\$ Right! There definitely are Arduino / ESP32 libraries for driving the APA102, but I'm not sure if they are using the underlying I2C hardware. I need to be able to write to the I2C chips at the same time as using the LEDs. Even though I see people writing "SDA" and "SCL" for an APA102, which would indicate I2c, I also see people saying that the APA102 is a kind of simplified SPI interface. If I can drive it with SPI then I think my I2C peripherals will be undisturbed for sure. I'll try to find an example. \$\endgroup\$
    – legoblocks
    Jul 22, 2023 at 14:04
  • \$\begingroup\$ FastLED is one such great library, and they consider the APA102 to be an "SPI" LED. github.com/FastLED/FastLED/wiki/Overview \$\endgroup\$
    – legoblocks
    Jul 22, 2023 at 14:07
  • 1
    \$\begingroup\$ I don't think I've ever seen an i2c addressable LED so good bet yours do not use i2c. \$\endgroup\$ Jul 22, 2023 at 14:09
  • \$\begingroup\$ No offense, but why did you post an answer that's basically what I wrote, albeit abridged? \$\endgroup\$
    – JYelton
    Jul 23, 2023 at 16:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.