Sound Reactive Floor Lamp
by Tesalex in Circuits > Microcontrollers
4536 Views, 2 Favorites, 0 Comments
Sound Reactive Floor Lamp
Hi! This project is an alternate version of my previous one, targeted for audience with prior experience in electronics. If you haven’t checked it out yet, do it first as it details the frame build. In this video we will only focus on improving the control circuit of the LEDs and see how we can add more features to it.
Supplies
We are going to completely scrap the SP108E and use our own circuit. The microcontroller we are going to use is ESP8266 developer module. You can also use ESP32 or any other Wi-Fi module with more than 4MB of flash memory. The firmware we will be using is called “WLED Sound Reactive”, which is an improved version of WLED. Now, you may ask what is WLED to start with? And to that I will say it is an open-source software to control neopixels like WS2812B, WS2811, SK6812 etc. over Wi-Fi. It has a tons of features which are mentioned in the webpage of WLED. Also, it has its own iOS and Android app, or if you want you can control it from the browser as well. What else can you ask for, right? Initially, I thought of working on my own firmware, but I quickly realized how big a hassle it will be. Also, I was not sure I will be able to execute all the features I originally thought of, as I am not a big-time coder. That’s when I found this. In comparison to what I had in mind, and with the SP108E also, I can easily say this is way better.
Now, coming to the Sound reactive part, the user Andrew Tuline made some changes to the code on top of the open-source WLED code to enable sound reactive features which we will see later in the video. It is obvious that to add sound reactive features, we will need a sound sensor. And I request you to refrain from using a digital output sound sensor because it will not give the effect we are looking for. Instead go for an analog output sound sensor, like the one I am using, MAX9814. You can use any of the sensor from the list in the SR-WLED webpage, or you can build your own using LM358 op-amp. It is fairly easy. After you have decided the sound sensor you are going to use, we can move on to the next part.
Please find the list of parts with their links below.
IN:
ESP8266 - https://amzn.to/3DXoe6x
ESP32 - https://amzn.to/3v5yh5E
MAX9814 - https://amzn.to/3xg4Jox
US:
ESP8266 - https://amzn.to/3rfsppi
ESP32 - https://amzn.to/3E1BBmu
MAX9814 - https://amzn.to/3O1ReyT
UK:
ESP8266 - https://amzn.to/37y7hn2
ESP32 - https://amzn.to/3Jp9yyf
MAX9814 - https://amzn.to/35XHbcV
Watch the Video
Go and watch the video first to get an in-depth understanding of how things are working.
The Frame
Check out my previous instructable where I go into details of building the frame.
https://www.instructables.com/Aesthetic-Floor-Lamp/
Using WLED
Firstly, I visited the WLED website. This webpage has every detail you will ever need to install and use WLED. I downloaded the latest firmware for my board and connected my board using micro-USB cable. To upload the firmware, we will need esptool. If you don’t have it, you can easily install it using the pip command, and for using pip command you will need to have the latest version of Python installed on your system. I will add link to a webpage which has detailed steps on how to install esptool. I opened command prompt and used the command shown in WLED webpage to flash the firmware to ESP8266. If you are facing trouble after uploading the firmware, try to erase the flash and then upload again. I disconnected the ESP8266 after uploading and brought in the WS2812B LEDs to test. I connected the data pin to pin D4 of microcontroller and connected the 5V and ground of both the board and led strip to my power supply using an alligator clip. If everything is done correctly, the first 30 LEDs should light up in orange, but it didn't at first in my case. The reason of failure is the poor way of connecting the power supply which is introducing a lot of noise. If we provide power separately to ESP8266 using USB cable it is working fine. Also, if we connect ESP8266 to power source properly using separate cables, there is no noise. This was to tell you how sensitive it can be and how important it is to power it correctly. It is recommended to use same power supply for both the strip and the board, and it obviously can’t be the USB cable.
It is time to connect to the access point of ESP8266 using SSID and password from the WLED webpage. Once connected it will take you to a webpage to choose if you want to continue using it in AP mode or want to use the STA mode. If you are going to install it permanently it is highly recommended to use STA mode. So, I went ahead and provided the details of my home network, pressed save and connect which will cause it to restart and connect to that network. Now it is easy enough to find its IP address and navigate to that using a browser which greets us with a bunch of controls. Try out some effects and colors and we are done with the WLED test.
MAX9814
Now, we can test you sound sensor if it is working correctly or not. I have made some modification to the module. I desoldered the electret microphone and connected two wires to it and then connected it back to the module as it was connected previously. This is to extend the microphone so that it can pick up audio signals more efficiently when it is installed in the lamp.
Now in the breadboard connect the Gain pin to Vcc to set its gain to 40 decibels. This is suggested in the SR WLED page itself. Make other connections as shown and upload the code attached in this step. Use Arduino serial plotter to check if the sensor works. Do not try to see it in the Serial monitor as the values will change very quickly and you will not be able to see any change.
Downloads
SR WLED
Finally, it is time to upload the sound reactive WLED code and test it out. This time I will show you how you can flash the ESP8266 using NodeMCUPyFlasher, just for the sake of diversity. You can use any of the tools mentioned on the website, out of which, two methods I have shown you in this instructable. Just make sure to erase the flash memory before flashing new binary. Go to the SR WLED webpage and download the binary file for your board from there. Do not download the pre-release or beta version of the binary, download the latest one. In the NodeMCUPyFlasher, select the options like as shown in the attached image, connect your board, make sure only one microcontroller board is connected to your computer and hit Flash NodeMCU. After completion, I connected the LED data pin to D4 and sound sensor analog out pin to A0 pin of ESP8266 and applied power to all components in a proper manner. Follow the steps like we did for WLED to connect it to your home network and find the IP address. Once you know the IP address, go there and you will be greeted with control panel looking similar to the WLED control panel. The difference is in the modes here. The modes that have an asterisk in front of their name are sound reactive modes. One important thing you will have to do here is go to config and adjust the sound settings. For MAX9814 the gain and squelch are suggested to be 10 and 10 respectively. Start with the suggested values for your board and adjust it until the LEDs doesn’t react to ambient noise and reacts well to the loud noises only. More details on gain and squelch can be found on the webpage. Do a quick test with different sound reactive modes and we can move on to making the setup more permanent.
I soldered all the components in a perfboard, and before choosing the size of the perfboard make sure it fits in you lamp.
Finalize
I connected the finished board to LED strip for final test and applied power. Everything seems to work fine. I used some masking tape to isolate the connections on the perfboard. I am not using hot glue because I might make some changes to the circuit in the future.
I removed the old SP108E controller from my lamp and connected the new controller to the strip. I attached the sound sensor and applied power to check if everything is working. Only the first 30 LEDs lit up. That is ok as it is the default no. of leds, and we can easily change it in the config page. After changing the no. of LEDs, it works fine.
I placed the controller inside the Aluminium block, but I got to do something about the wires protruding out of the lamp's top.
Problems and Solution
For hiding the wires, I changed positions of the screw terminals and soldered it besides screw terminals. Also, I changed the wires for data in and analog out because old ones were causing a lot of cold solder joints. Now for hiding the wires, changing screw terminals position also didn’t help. So, I drilled three holes besides the strip and passed wires through them inside the block and connected to the controller board. While desoldering the wires I accidentally chipped off the data in pad of the first LED, so I decided to skip it and connected data pin to Din pin of next LED, and guess what, it doesn’t work now. After hours of debug, I learned an interesting thing. If you try to provide data to next LED without removing connection from previous LED, WS2812B won’t work. I am not sure if this is true for other addressable LEDs as well or not, if you do let me know in the comments below. So, to make it work you will have to remove the previous LED. I decided to take a different route and connected the data pin directly to the first LED Din pad (check the attached image). It works as expected now.
Few more things before I sign off. If you are recreating this lamp, you might want to reverse the data direction in config because some sound reactive effects, and even some normal effects for that matter may work top-down instead of bottom-up which is what is generally expected.
Another thing is the inconvenience of LEDs not remembering their mode and color after restart. There is a good reason for this, which you can read about in this webpage. The gist is that you can enable the mode saving feature, but it requires writing to the EEPROM every time you change a mode or color and EEPROMs have a limited write cycle, so depending on how you use it, your board can die way sooner than expected. The best solution is to use presets. To do that, chose your favorite mode and color pattern, create a preset and save it. Then in the LED config, change the setting in LED preferences, change "Apply Preset" option to load your saved preset number during start-up and save it. Now next time when you restart it will load this preset instead of making the LEDs orange.
Another inconvenience is there is no app for sound reactive LWED firmware. And the IP address of ESP8266 is subjected to change after a restart as most routers assign IPs dynamically until you manually change the setting. To overcome this, you have an option to assign a static IP from the config of WLED itself, but I do not suggest to use this as you router may still assign that IP address to another device. Another option is to assign static IP to ESP8266 from the router itself. Most routers have the option to assign static IP to a device using its MAC address which can be easily determined from router config. The best and final option is not to use IP addresses at all. Instead use the HTTP address mentioned in the Wi-Fi settings config page and it will always take you to the WLED control panel. You can also create a shortcut like I did and with just one click you are there. You won’t be able to tell a difference between using this and using the app.
Lastly don’t forget to check the "It is not working" webpage if you are facing any problems. Most likely your problem with solution will be provided there.
Supporting Links
I am adding a few links below which can be helpful while building this project.
WLED wesbite: https://kno.wled.ge/basics/getting-started/
SR-WLED wesbite: https://github.com/atuline/WLED/wiki
How to install esptool: https://cyberblogspot.com/how-to-install-esptool-on-windows-10/
Remeber last state after reboot discussion: https://github.com/Aircoookie/WLED/issues/1926
Arduino EEPROM write cycles limit: https://www.youtube.com/watch?v=McK2PSUxjck
Done!
That was all for this one. If you enjoyed and learned something new, please like and share. Also subscribe to our YouTube channel to get the latest updates. Till next time :)