Ledstrip Audio Visualiser for CoreElec using ESP8266. This is a working release, although things can be improved. Soe effects from the original work of Wirekraken have not been migrated yet. Also the HTML page to control the LED strip is not great.
- Visualise audio on a LED scripts. The LED strips works as an equalizer with some logic to add a strobe effect.
- LED effects like fire and rainbow
- Broadasts audio data over UDP, so multiple strips can recieve audio data simultaniously
- Controllable over HTTP and JSON interface
The python module and CAVA run on the HTPC, broadcasting audio data over Wifi to 1 or more LED strips. CAVA can use both Pulseaudio and ALSA as audio source. From a browser or using HTTP post calls you can control each individual LED strip.
ESP/LEDstrip Image by wireKraken https://github.com/wirekraken/ESP8266-Websockets-LED
The following requirements apply to use the software
- LED strip supported by FastLED. I tested using a NEOPIXEL 144 LED strip
- ESP8266 board with Wifi, compatible with Arduino ESP
- A AMD64 or ARM64 machine that can run the pyhton and CAVA modules
Based on https://github.com/nvbn/soundlights, uses the broadcast logic to broadcast audio information onto the network
Uses CAVA https://github.com/karlstav/cava to convert audio into a data stream. In the releases is a CAVA build included compiled against CoreElec and one compiled against Linux Mint 20.1 64-bit. Pulse audio and ALSA are supported in the build
CoreElec 19.3 https://coreelec.org/ / KODI https://kodi.tv/ compatible, so you can connect the LED strip to your HTPC. Although LibreElec compiled for AMLogic also should work.
Requires Python3 https://www.python.org/ (already included on Mint and Coreelec
Based on the great work of Wirekraken https://github.com/wirekraken/ESP8266-Websockets-LED Basically I have forked his work and rewrittten a big part of the code to be more modular and object oriented. Also I have extended the code with UDP support and a configuration module.
Requires Arduino https://www.arduino.cc/ to compile the ESP8266 application.
Requires ESP8266WebServer https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WebServer to provide a simple web interface to control the LED strip
Requires FastLED https://github.com/FastLED/FastLED 3.4 to control the LED strip
- Change the WIFI parameters (ssid, password and IP) in soundlights.ino to match your network.
- In LEDStrip.h change LED_COUNT to the number of LEDs in your strip. And change LED_DT to the i/o pin number on which the LED strip is attached
- Compile and upload the software to the ESP module
- Upload the HTML and CSS files from the data directory using 'Sketch data upload' in the Aruino Tools menu.
In the release a precompiled CAVA version for AMD64 and CoreElec Amogic-ng build is avaiable. But if you manually want to compile CAVA you can follow these steps
Download CAVA https://github.com/karlstav/cava and the dependencies, following the instruction to build CAVA.
Download and compile Coreelec 19.3 from https://github.com/CoreELEC/CoreELEC/tree/coreelec-19
Download CAVA https://github.com/karlstav/cava and the dependencies
Compile CAVA against the CoreELEC build
export CPPGLAGS="-I<CoreELEC path>/build.CoreELEC-Amlogic-ng.arm-19/toolchain/lib"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/aarch64-linux-gnu/lib/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/<CoreELEC path>/build.CoreELEC-Amlogic-ng.arm-19/toolchain/lib
export CC=<CoreELEC path>/build.CoreELEC-Amlogic-ng.arm-19/toolchain/bin/armv8a-libreelec-linux-gnueabihf-gcc
OST_OS=linux ./configure --target=aarch64 --disable-output-ncurses --host=amd64 --disable-input-portaudio --disable-input-sndio --disable-output-sdl
These instructions apply to CoreELEC with Kodi, but can be adapted to any Linux installation
- Create a directory /storage/soundlights and place here cava, cava_config,kodileds.sh and client.py from the release.
- Adjust in cava_config the line bars = 144, replacing 144 with the number of LEDs in your strip.
- To the same for the line NUM_BARS=144 in client.py
- Create a file /storage/.config/autostart.sh with
#!/bin/sh
pactl load-module module-udev-detect
pactl load-module module-null-sink sink_name=recsink
pactl load-module module-alsa-sink device=hw:0,0
pactl load-module module-loopback source=recsink.monitor sink=alsa_output.0.hdmi-stereo
This may need ajusting depending on your exact hardware.
Run nohup /storage/soundlights/kodileds.sh & to start the module
Make sure to change the Kodi settings to use the pulseaudio device
Connect to the IP adres set in the ESP module and the followig interface should appear. Select the desired mode and the LED strip should immediately change. For some modes you can set the color, speed and birghtness as well.
You can request the currect setting using a HTTP GET, which will return a JSON string
{ "mode":<mode number>,
"red":<red intensity 0-255>,
"blue":<blue intensity 0-255>,
"green": <green intensity 0-255>,
"brightness": <LED strip brightness 0-255>,
"delay": <speed delay in ms>
"color": <RGB value in HEX format>}
You can send using HTTPS POST a JSON string to /config/set in the following format:
{"mode":<mode number>,
"red":<red intensity 0-255>,
"blue":<blue intensity 0-255>,
"green": <green intensity 0-255>,
"brightness": <LED strip brightness 0-255>,
"delay": <speed delay in ms>
}
You can set a signle value posting a value in the HTTP body to the URL /config/set/
For example posting the value 30 to http://xxx.xxx.xxx.xxx/config/set/, will change the current mode to 'Sound visualizer'
For the color property a comma seperated string with rgb values is required. For example 255,0,0 for red.
You can control the LED strip from Openhab using the HTTP binding. Add a HTTP thing and set the following parameters:
Base URL: http://xxx.xxx.xxx.xxx/config/set
Command Method: POST
Content Type: application/json
Now you can add a channel for each configuration paramter. For each channel set
State Transformation: $.<property> i.e. '$.color'
State URL Extension: <property> i.e. 'color', this will ost the value to http://xxx.xxx.xxx.xxx/config/set/color