nanoFramework.Iot.Device.Apa102 1.2.1040

Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.Apa102 --version 1.2.1040
                    
NuGet\Install-Package nanoFramework.Iot.Device.Apa102 -Version 1.2.1040
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="nanoFramework.Iot.Device.Apa102" Version="1.2.1040" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nanoFramework.Iot.Device.Apa102" Version="1.2.1040" />
                    
Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.Apa102" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add nanoFramework.Iot.Device.Apa102 --version 1.2.1040
                    
#r "nuget: nanoFramework.Iot.Device.Apa102, 1.2.1040"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package nanoFramework.Iot.Device.Apa102@1.2.1040
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=nanoFramework.Iot.Device.Apa102&version=1.2.1040
                    
Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.Apa102&version=1.2.1040
                    
Install as a Cake Tool

APA102 - Double line transmission integrated control LED

APA102 is a intelligent control LED light source that the control circuit and RGB chip are integrated in a package of 5050/2020 components. It internal include 3 groups shift register and Selfdetection sign decoder circuit.

It's different from WS2812. In addition to the data line, it has a clock line. So APA102 has no strict requirements for timing. It's more friendly to devices such as Raspberry Pi that can't precisely control the timing of data lines.

There are other models like APA107, HD107s, SK9822, etc. The controls are exactly the same.

Model SCLK PWM
APA102 20 MHz 20 kHz
APA107 30 MHz 9 kHz
HD107s 40 MHz 27 kHz
SK9822 15 MHz 4.7 kHz

Documentation

Usage

Important: make sure you properly setup the SPI pins especially for ESP32 before creating the SpiDevice, make sure you install the nanoFramework.Hardware.ESP32 nuget:

//////////////////////////////////////////////////////////////////////
// when connecting to an ESP32 device, need to configure the SPI GPIOs
// used for the bus
Configuration.SetPinFunction(21, DeviceFunction.SPI1_MOSI);
Configuration.SetPinFunction(22, DeviceFunction.SPI1_MISO);
Configuration.SetPinFunction(23, DeviceFunction.SPI1_CLOCK);
// Make sure as well you are using the right chip select

For other devices like STM32, please make sure you're using the pre-set pins for the SPI bus you want to use. The chip select can as well be pre setup.

Here is an example how to use the APA102:

using System;
using System.Device.Spi;
using System.Drawing;
using System.Threading;
using Iot.Device.Apa102;

var random = new Random();

using SpiDevice spiDevice = SpiDevice.Create(new SpiConnectionSettings(1, 42)
{
    ClockFrequency = 20_000_000,
    DataFlow = DataFlow.MsbFirst,
    Mode = SpiMode.Mode0 // ensure data is ready at clock rising edge
});
using Apa102 apa102 = new Apa102(spiDevice, 16);

while (true)
{
    for (var i = 0; i < apa102.Pixels.Length; i++)
    {
        apa102.Pixels[i] = Color.FromArgb(255, random.Next(256), random.Next(256), random.Next(256));
    }

    apa102.Flush();
    Thread.Sleep(1000);
}
Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0-preview.121 43 8/31/2026
2.0.0-preview.109 54 7/13/2026
2.0.0-preview.102 63 7/6/2026
2.0.0-preview.94 79 6/22/2026
2.0.0-preview.85 66 6/1/2026
2.0.0-preview.80 72 5/27/2026
2.0.0-preview.73 61 5/20/2026
2.0.0-preview.69 69 5/18/2026
2.0.0-preview.62 65 5/13/2026
2.0.0-preview.49 59 5/4/2026
2.0.0-preview.45 69 4/29/2026
2.0.0-preview.40 67 4/27/2026
2.0.0-preview.37 69 4/22/2026
2.0.0-preview.32 75 4/20/2026
1.2.1040 71 8/31/2026
1.2.1027 121 8/3/2026
1.2.1016 121 7/13/2026
1.2.1002 122 7/1/2026
1.2.994 118 6/24/2026
1.2.991 126 6/22/2026
Loading failed