0

I would like to control addressable RGB LEDs (ws2812b / NeoPixels) from a program on a computer running Linux.

Seems that most gaming-grade motherboards have some sort of direct 3-pin port for such LED strips, controllable through a vendor-specific system (Razer Chroma, Asus Aura Sync...) . But I am using a mini PC that does not have this feature.

I am looking for some sort of USB interface on which you can plug the addressable LEDs strip on the other end, eventually with any required additional power supply in case the USB-supplied current is not enough.

I would also like to be able to use a simple API or library to control the LEDs without requiring installation of a proprietary SDK or driver which is, often, designed to work on Windows only and quite heavy. I need exact control of the pixels with a fast enough framerate, and do not want to be limited to a selection of preset animations, for example.

Solutions that involve wifi, bluetooth, any kind of networking configuration or pairing process are excluded.

As last resort, I can tinker with an Arduino, using the Adalight firmware and protocol. But, if something is available off-the-shelf for the purpose, I would save time on the project.

DavGin
  • 101
  • Since you're planning on using WS2812B/NeoPixels, why not use WLED? It supports tons and tons of different controllers. – JMY1000 Jan 23 '24 at 06:08
  • Do you have experience using WLED over USB? Interesting project, but there seem to be very little documentation and readily-made solutions that involve streaming data over USB. They put a lot of emphasis on using the web interface and accessing through the network. – DavGin Jan 23 '24 at 13:09
  • I mean if you're using an ESP32, you can really interface with it however you want. JSON over Serial using USB probably makes the most sense; this ESP uploader board could be a good choice. If that's too much though, you could just buy a commercial RGB controller and use OpenRGB; it's not as flexible or programmable, and you'll be relying on a a proprietary controller from Asus/Corsair/whatever, but you'll still have an SDK that you can use on desktop without too much hassle. – JMY1000 Jan 23 '24 at 22:47
  • I've made something like this for myself with an Arduino and a .NET program using the SerialPort class to talk to the Arduino over COM. Lots of good suggestions above if you want something "ready made" but this is extremely easy to DIY anyway. – Romen Jan 26 '24 at 22:13

1 Answers1

0

Among the off-the-shelf solutions there are controller boxes such as Razer Chroma, but it is quite big and has the proprietary protocol limitation.

Closest to what I needed is a small box with some peculiar use of a barrel jack connector, from this Aliexpress seller : https://www.aliexpress.com/item/1005003390054760.html. They use the barrel jack to output the data, corresponding to the wiring of the provided LED strip. The box uses Adalight protocol and is much smaller than those from the PC hardware vendors.

I ended up hacking a small circuit using an Arduino Nano, while the delivery was on its way. It works on the breadboard so far.

Tested the good working of both solutions using Prismatik (an Ambilight-style renderer for Linux), which was satisfactory. Windows users can use Hyperion.

Custom control from software

The following involve the understanding of communication protocols and a bit of programming knowledge. This is why I let the answer here, because it mixes coding (would fit on StackOverflow), electronics (perhaps better for EE Stack Exchange), it is a bit of a mixed bag.

I have not found any standalone library that implements the following so far. Likewise, documentation of the protocol is hard to come by without digging into the source code of Prismatik or similar. The information below is provided to compensate this.

My small experimental program opens the serial port device associated with the controller at 112500 bauds. COM1 or similar on Windows, /dev/TTYUSB0 or similar on Linux. On some Linux distributions like Ubuntu, make sure to add yourself to the dialout group so that you have the permissions to access the serial port, for instance.

First, the controller responds with the "Ada\n" string (4 characters in total), you need to read those from your code before anything else or the lights will not show. You can also confirm that your device is your actual controller with the appropriate firmware, and not something different.

Over the line, I send the following bytes to change the colors:

0 : character 'A'
1 : character 'd'
2 : character 'a'
3 : hi (Number of LEDs to send - most significant byte)
4 : lo (Number of LEDs to send - least significant byte)
5 : checksum

6 : LED 1 red 7 : LED 1 green 8 : LED 1 blue 9 : LED 2 red 10: LED 2 green 11: LED 2 blue .... and so on, you need to send the exact number of values for the number of LEDS you have passed at offsets 3 and 4.

Here is an example in C++ on how to calculate hi, lo, and checksum. The number of LEDs is a 16-bit value, that must be split over two bytes 'hi' and 'lo'. You can use a different language to implement this such as Python, maybe more convenient for tinkering and does not require to compile the program.

int num_leds = 16; // Adjust to your situation

int hi = ((num_leds - 1) >> 8) & 0xFF; int lo = (num_leds - 1) & 0xFF; int checksum = hi ^ lo ^ 0x55;

Details on the Arduino-based solution

Beware, the explanations deal a lot with electronics tinkering. You can use those and prototype this on a breadboard without soldering. Be really careful of not messing up polarity of components, or you can fry those! Use those instructions at your own risk.

I have flashed the Adalight firmware on the Nano available here: https://github.com/hyperion-project/hyperion.ng/blob/master/assets/firmware/arduino/adalight/adalight.ino. Use Arduino IDE to flash the board.

Note : should be customized with the number of LEDs you have on your strip / line / whatever.

Then link the 5V / red wire to Arduino 5V, ground / white to GND, Data / green to D6 pin with a 470 ohm resistor in between.

If there are a lots of LEDs, there should be an external power supply attached between 5V and GND directly with a 1000µF capacitor in between. I tested with a 16-led ring and the USB power was sufficient, even at full brightness, did not need to use the external power supply and the capacitor.

By using some standardized electronics headers, it is easy to reproduce the 3-pin connection found on motherboards. Otherwise, many daisy-chainable addressable LED modules use 3-pin JST SM connectors. A female pigtail wire of the sort can be used as the source of the LED installation.

DavGin
  • 101