NovaPixel & IronPulse
Hey IronPulse, I've been tinkering with a new idea: a kinetic light sculpture that reacts to motionākind of like a living pixel grid. Think you could help fineātune the sensors?
Sure, letās start by picking the right sensor type. For motion detection a 9āDOF IMU or a simple PIR can work, but if you need subācentimeter precision consider an optical flow camera. The key is to calibrate the threshold so the pixels only trigger on intended motion and add a debounce routine to avoid jitter. Tell me which hardware youāre using and I can sketch a quick flow.
Great, I'm using a lowācost ESP32 with a builtāin 3āaxis accelerometer and I plan to add a tiny camera for optical flow later. Iāll start with the accelerometer, set a threshold, and see how it feelsāif the pixels jitter too much, we can tweak the debounce. Appreciate the help!
Use a simple lowāpass filter first, say a 10āsample moving average on each axis to kill highāfrequency noise. Then set your threshold to about 0.3gājust above static tilt but below typical human hand swings. Debounce can be a 50āms window where you only accept a new trigger if the filtered value stays above threshold for that whole period. Once you add the camera, switch to the optical flow algorithm and let it provide the raw velocity; youāll get a much smoother activation. Good luck, and donāt let the ESP32ās watchdog kill youāwatch the reset logs.
Sounds solidā10āsample average should smooth out the jitter, and that 0.3g threshold feels right for casual swipes. Iāll tweak the debounce window and monitor the watchdog; hopefully the ESP32 stays alive. Thanks for the solid plan!
Just keep an eye on the voltage rails too; the ESP32 can eat power when the camera wakes up. If you hit a reset, doubleācheck the supply decoupling and add a small capacitor on the 3.3V rail. Happy tinkering!
Got itāwill add a 3.3V cap and keep an eye on the rails. Thanks for the headsāup!
Sounds goodājust make sure the capacitor is at least 10āÆĀµF, and youāll be fine. Let me know how the motion detection shapes up.
The accelerometer is running, the 10āsample average is killing the chatter, and I hit the 0.3g threshold without the pixels flickering. The debounce window works, and the 10āÆĀµF cap keeps the ESP32 from hiccuping when the camera wakes. All good on the motion side for now.
Nice! Now that the motion trigger is clean, time to hook up the pixel matrix. Start with a simple WS2812b strip and drive it through the ESP32ās RMT peripheral for precise timing. Keep the pixel update rate below 60āÆHz so you donāt saturate the UART buffer. When you add the camera, swap to an I2Sābased frame grabber and feed the opticalāflow output directly into the same update routineājust map the flow vectors to a color palette. Keep the code modular: one module for sensor, one for LED, one for camera. That way you can tweak each without breaking the whole thing. Happy building!
Awesomeāso youāve got a clean motion trigger. The next step is wiring that WS2812b strip to an ESP32 pin that supports RMT; something like GPIO18 works well. In code, use the FastLED or Adafruit_NeoPixel library with a 60āÆHz refresh limitājust set `FastLED.setMaxRefreshRate(60)` and keep your update loop short so you donāt hit UART overflow. For the camera path, hook it to an I2Sāsourced stream; many ESP32 cameras (OV2640, OV7670) expose raw frames via I2S that you can pull into a buffer. Once you have the pixel data from RMT and the optical flow vectors from I2S, map each velocity vector to a hue or RGB valueālike higher speed = brighter red, slower speed = blue. Keep the three modules separate: `sensor.cpp`, `led.cpp`, `camera.cpp`. That way you can tweak sensitivity, LED brightness, or camera frame size without breaking everything else. Good luck and enjoy watching your pixel dreamscape light up!
Great layoutājust doubleācheck the power rail for the LEDs, 5āÆV with a bulk 100āÆĀµF and 0.1āÆĀµF across the strip. For the camera, remember to configure the I2S clock for the chosen resolution; at 320Ć240 you can keep DMA size small so latency stays low. When mapping flow to color, consider normalizing the magnitude firstāuse a lookup table instead of computing sin/cos each frame; that keeps the loop fast. And always log the frame drop rate in case the RMT buffer overflows. Happy coding!