I’ve been working on an interactive art project as a favour for a friend of mine that would allow you to push buttons, use rotary encoders, potentiometers and so on in order to control an animated light fixture elsewhere in the room.
These controls would allow you to change:
- Brightness
- Display mode
- Palettes
- Speed
- Toggle direction
- Toggle glitter
- and so on. . .
To do so, I’m using an ESP8266 enabled FastLED based lantern combined with an ESP32 based control panel. They’re both MQTT enabled, and I’ll be using an Android phone as the wifi hotspot and MQTT broker.
Here’s an email I sent about my progress in wiring and initial coding for the control panel:
I finished wiring up all the pins this morning and . . .
ABSOLUTELY NOTHING WORKED. Wouldn’t even upload to the ESP32. Got out the voltmeter and started measuring:
- LED was wired backwards (causing it to not upload), so I removed it temporarily.
- Some pins didn’t support internal pullup so I had to do some research and re-wiring.
- Didn’t set internal pullup correctly in the code. Found and fixed.
- Got digital pins working with basic digitalRead().
- Found an ESP32 button library, so I don’t have to worry about de-bouncing.
- Got that working with multiple buttons.
- Had to rename the analog ports and got the potentiometers working. Values were backwards, but math fixed that.
- Had previously successfully tested a rotary encoder library, so I added the code.
- One rotary encoder wasn’t working. Swapped wires, was the same encoder. Pins were OK.
- Had a rotary encoder soldering issue (solder blob). Fixed that and got both working as well.
- Soldered on a new WS2812 LED. Installed FastLED and got that working once I found a compatible pin.
- Got some ESP32 network code. It compiled.
- Got my old MQTT networking code. It compiled as well.
- Have smushed together my wifi/MQTT code with FastLED and the various inputs.
- Amazingly, it all still compiled.
Next step will be to start adding MQTT publishing functionality to each of those inputs.
So far so good. This shit takes time to do though. As <other friend> well knows, it can take a LOT of time.
In summary, things typically don’t go as expected, so it can boil down to troubleshooting techniques. Divide and conquer.
Update: The next day, I had the buttons and potentiometer working just peachy. Only problem is, that my mode selector was meant for buttons and I was trying to use a rotary encoder for that. Now have to change code for both the control panel as well as the lantern to accept the values provided by the rotary encoder. Have also got the LED on the control panel to show Red when there’s no network connectivity, Orange when it’s connected, and finally Green when both wifi and MQTT are connected.