Control APA102 LEDs attached to Raspberry Pi.
- Raspberry pi with octoprint
- APA102 LED attached to rpi
- rpi is 3.3v and APA102 is 5v device. Correct solution would be usage of level shifter as described here. But from our experience it works just fine without level shifting.
- LED 5v <-> rpi 5v (in case of just one or two leds; longer strip needs separate power source or it may end up with demaged rpi)
- LED ground <-> rpi ground
- LED data <-> rpi SPI MOSI
- LED clock <-> rpi SPI SCLK
-
Install via the bundled Plugin Manager or manually using this URL:
https://github.com/fragaria/karmen-led-octoprint-plugin/archive/master.zip
-
Enable SPI interface on RPI (official documentation)
- On desktop use "Raspberry Pi Configuration" dialog or
- From terminal run
sudo raspi-config
and inInterfacing options
enableP4 SPI
or - Edit
sudo nano /boot/config.txt
and uncommentdtparam=spi=on
line.
Plugin has two modes of operation - API and automatic. Modes can be switched in plugin's settings.
To turn LEDs on send POST request to /api/plugin/awesome_karmen_led
with json body {"command": "set_led", "color":[<R>, <G>, <B>]}
where <R>
,<G>
and <B>
are numbers from 0 to 255.
Example:
curl http://<rpi_hostname_or_ip>/api/plugin/awesome_karmen_led --header "X-Api-Key: <YOURAPIKEY>" -X POST -d '{"command": "set_led", "color":[255, 255, 255]}' -H "Content-Type: application/json"
Colors are changed automaticaly by connection and print events.