RGBWW Led Strip: Can I Sync Music via ESPHome?

Thanks to @nickrout I am in the midst of creating an audio signal sensor on an ESP32, which seems to be able to detect dB (or some measurement of “sound level”).

I will be using the same ESP32 to drive an RGBWW strip. Is there a script I could add to the ESPHome config to sync the LED strip with the readings on the audio GPIO input? Maybe some Lambda effects with a very short update_interval?

If audio sync’d LED’s is your end goal then I would suggest using ‘Sound Reactive WLED’ instead of ESPhome. It’s currently a fork of regular WLED but the upcoming version 14 is going to have that included as standard. The beta is already available.

Thank you @sparkydave. I’ll give that a look. I would prefer to not need a second microcontroller just for arduino code (I need to use ESPHome for other devices in the same project). I believe arduino libraries can be embedded into an ESPHome config, and if so I should be all set. I have ordered an MSGEQ7 and I see that I’m not the first to go this route.

Is there a way to add SoundReactive WLED to an ESPHome config, so I don’t need to use a separate ESP32? I’m already at three ESP microcontrollers for my project and I’d rather not add a fourth if I don’t need to.

I presume not. But I’d like to ask.

For those who are interested, I’m leaning heavily toward using MLSC.

It looks pretty neat. Go ahead and give that link a click.

I don’t know if/how I can get it to work with HA. For instance, I would prefer to be able to control it (at least activate and deactivate it) from my HA server, perhaps through API calls. I am a total novice but perhaps in time I’ll figure out a way to integrate it with HA in some respect.

Edit: Indeed, once MLSC is installed, it hosts a web UI, and on this UI there is a link to a list of API commands. So, one should be able to control each individual LED strip through the API (as well as the web UI, of course) This MLSC is quite a nice piece of software. I am surprised there isn’t more discussion of it.

Edit: I’ve posted some examples of REST commands I’m using to edit/activate effects from HA via the API.

I’ve also created SSH keys so I can shut down my MLSC RPi4 from HA. See below.

  - platform: command_line
    switches:
      raspberry_pi_shutdown:
        command_on: "ssh -i /config/ssh_keys/pi -o StrictHostKeyChecking=no [email protected] sudo /sbin/shutdown -h now"
1 Like

Great tip! Thank you.
I would give a try on MLSC for this Christmas.
I would prefer to have something directly integrated into Home Assistant / ESPHome, but the problem I am facing is the data sender software, I mean, in ESPHome there is support for E1.31 protocol (sACN) which is great! But the best software I could find to control this protocol was Jinx! v2.4 (exclamation mark included). The problem is, Jinx! only works on Windows environment. I already have a good Debian configured to an Intel 64 bits server, command line only, which runs my HA instance. I don’t want to have another Windows machine dedicated to only host Jinx! all the time, I also don’t want to have to power on and configure the software each night only to light up everything, I prefer to set this running all the time and only code an automation to turn on all the lights already in E1.31 mode every sunset.
The author already said that his software will not have a port for Linux environments, one can check this at Jinx!'s website, FAQs: http://www.live-leds.de
Meanwhile, I’ll try to find easier and integrated ways to run distributed light effects across many ESPs with HA.

MLSC is really fun. The effects are great, and there is the ability to create your own as well. A few things to note:

  1. In the MLSC Discord channel it has been mentioned several times that the dev_2.3 version includes features that are lacking in the master (2.2 release). I have tried to install dev_2.3 on my Pi4 with no success. My issues seem to relate to python 3.8 (which dev_2.3 requires, and which I have successfully installed, multiple times for multiple separate attempts), pip, numpy, and/or scipy.

  2. If you will be using a USB wifi adapter to connect your Pi to your network, you can search for my recent instructions in the Discord channel for how to do so. Search for “wlan1” in the support chat.

  3. The Discord chat doesn’t seem to be a reliable way to get one’s questions answered. I have asked some that have been entirely ignored. It’s a channel with low activity in general.

  4. From my experience on my Pi4, there is no way to use two GPIO pins on the Pi for LED data output. The FAQ says it is possible but I have spent a lot of time trying to get it to work and ultimately I have concluded that, at least on the Pi4 B 8GB, only one GPIO output can be used.

  5. The ESP clients seem to have no delay; they flash with music at the same time as the Pi GPIO output strip, so #4 is not much of a burden since one can replace the second LED GPIO with an ESP easily.

  6. ESP32 clients are working great for me. I just replaced the ESP8266 wifi library (ESP8266WiFi.h) with the ESP32 wifi library, at the beginning of the arduino sketch.

  7. When adding an ESP client to the MLSC settings, the default IP address in the UDP Client IP Address is 127.0.0.1, which is a bit misleading because the IP you will need to enter will be the one you assigned to the ESP before you flashed the arduino sketch to it. …so the IP address is likely to begin with 172… or, 192… That’s the IP address that goes in this field, and you can check whether each ESP client is connected to the MLSC server by clicking System Status and scrolling down the page.

  8. If you do use a Pi GPIO output, for a WS2812B, you will likely need to modify the device settings for that LED strip. The default assignment is ws281x_default (or similar …I’m not able to check at the moment), and this default setting resulted in a swapped Red and Green on my Pi GPIO strip, so I set it to (I think it was) ws2812b_gbr and it works great now.

  9. You might want to shift your data logic from 3.3V to 5V. I have a thread in the arduino forum that explores this topic in detail. It’s quite drawn out. The takeaway is that the HCT Schmitt Trigger is the most advisable means for shifting the high frequency data that these strips use. The folks who contributed to my thread seemed very knowledgeable and their recommendation was the 74HCT14 or the 74HC14. I am using both, separately, with success. Do note that each gate the data passes through would be inverted, so the wiring would involve passing the data through two gates in series …and grounding the unused gates so they don’t float and create interference.

Edit: Here is a link to the way to use the 74HCT/HC. Scroll down to my next post in that thread and you will see the diagram of where each pin falls, so VCC connects at the top-left (pin 14) and GND connects at the bottom-right (pin 7). Just run that GND from pin 7 to any unused pins on the board and you won’t get interference from them.

1 Like

Wow! Thanks a lot for this huge help!
I’ll probably start fiddling with this next week, let’s see how it goes.
If I found something interesting (or a problem), I’ll share with you, here.
I looks very promising. Sure I’ll need more ESPs, and I’m excited with this!

Best regards!