I’m currently upgrading to WLED from a home-brewed Teensy based FFT setup that I wrote/built during lockdown, so please assume limited knowledge of WLED at this point. I’m also in awe of how much WLED is able to do - thank you all for that.
The home-brew system used a line-in as its primary source but also had a ‘backup’ microphone and I would like to try to replicate the same behaviour in WLED using a physical switch to swap between line-in and mic I2S sources. I would be happy to [programmatically trigger a] reboot when switching as it isn’t something that happens frequently.
The WLED software installed is Sound Reactive v0.13.4 - I would be happy to use the core SR if I could work out how to install the ‘Audio Responsive Hue’ colour palette as this, combined with the Gravcenter effect most closely matches my main home-brew effect.
I only recently got I2S line-in and i have INMP441 so what i will try ( please note i am experimenting a lot and do not mind killing hw ) is to wire both the I2S mic and I2S line and have a switch to alternate the power of both so only one device will have power at a time . Might work
I saw that example and it might well be a route I take - especially as my line-in board arrived today and I have yet to get it successfully working - all the wiring is good, but even when the ‘Info’ dialog says I2S is connected, it remains ‘Quiet’.
If you get yours running, please share the details - I’ll try again over the weekend but thought raising a question here twice in one day was a bit much for a newbie…
My initial thoughts were to share all the outputs from the ESP (WS/CLK, SCK, MCLK) and just switch (either physically or programmatically) the SD/DATA input to the ESP.
I suspect switching VCC and/or GND would cause issues if the other wires remained connected. I think I2S can have more than one device connected but that may be one input and one output rather than two inputs.
I have tested some i2s boards and the ones that needs MCLK ( ESP32 audio kit and PCM1808 ) only worked for me when i used gpio0 for MCLK ( i had to buy ESP32 relay board that exposed gpio0 for PCM1808 )
This is currently my working setup with ESP32 audio kit
For switching between I2S mic and line-in it would for sure be better to do that in code but as said i experiment a lot so switching power might be just a quick way out and i will only diconnect VCC so that is just to use one physical switch as you asked ( i still need to find another ESP32 relay board to connect the PCM1808 as I have it in a drawer right now so i could test this but will do that in few days )
Thank you very much for your reply - my original line-in to I2S arrived in a very battered box and I could not get it working (even after or because I’d had to straighten quite a few pins). So a quick visit to Digikey got me a PMOD I2S2 - which I still couldn’t get working until I upgraded from 0.13.4-SR to 0.14.4-SR - so my WM8782 might work too.
The reason for my upgrade reticence, is the ‘Audio Responsive Hue’ Colour Palette only exists in 0.13.4-SR and this is a non-negotiable for the effects I want (ie sound frequencies are mapped to colours so lots of bass equals lots of red etc).
So I’m going to hold off this part of the project until I can work out how to get the Audio Responsive Hue into later versions (will raise a separate question) but I’m sure I’ll be back.
I think most I2S will give a bit of headache as I seen with other guys but they all work and using latest AC or MM might be best as SR is somewhat legacy by now .
Audio Responsive Palette is still available in MM and also on AC version 15 so might be try that out
Spooky! I was just about to reply to say late last night I got the I2S was working successfully with MM version v0.14.1-b30 - including Audio Responsive Hue.
I think I will try to wire up both the in-line and the microphone and manually update the pin config to see if they play well when both are physically connected but only one is configured for use… If that works, then it’ll be a case of working out how to automate the config updates (json/cfg, I think) and linking that to a a switch (and a separate momentary to reset).
Nothing spooky about tech , SR might be only good if you are using analog line-in with bad wiring and that was a long time ago , at the moment no real advantage to using SR ( I still have very old units with that )
To change the config on the fly I use something like below ( a bit of a hack )
curl -F “data=@cfg.json” 10.0.6.70/upload
And wled will auto reboot if you do that , there is also a way to change the /json/cfg endpoint setting but I only tried that from postman , example listed here in discord
The bottom three buttons do all the work - the right button is ‘Restart’ (a standard part of the HA WLED integration) - this has to be pressed after toggling between line-in and mic.
The left (line-in) and centre (microphone) buttons make calls to rest commands in configuration.yaml:
I have now created a schematic & working rats nest prototype board (but for reliability, I’ll order a ‘proper’ PCB). If there’s any interest I’ll publish the details.
Edit: This is a board for an LED system that is already powered & fused, so this design is purely a controller, not for power distribution. It used the WT32-ETH01 board, a Pmod I2S2 line-in ADC and a INMP441 I2S circular microphone module.