The idea was simple: an irregular block of glass, a ring of coloured LEDs underneath, the whole thing as a gift. The plan called for off-the-shelf software and as little code of my own as possible.
What I ended up with is a device with its own firmware, a control panel in the phone’s browser, a reaction to music and to a hand, battery operation and a hookup to the home automation system. The project is called GlassShard, it ran from 10 August to 4 September 2026 and left behind 128 recorded changes to the code.
To be honest right from the start: the firmware for this device was written by an AI agent, that is, a program that writes code by itself, uploads it to the board and checks whether it works. I did the soldering, swapped modules and decided what mattered. This post is about what we learned along the way, and the most interesting lessons are not about code.


Simulator first, soldering iron second
The first thing that got built was not firmware for the board but a simulator of the ring in the browser. Every lighting mode could be watched on screen and the animations tested before any hardware existed at all. The parts list and the wiring diagram were then drawn up from the simulator.
That order paid off. The maths from the simulator was later carried over into the device’s firmware, so picking the effects before soldering was not wasted effort.

At the heart of it is a very small XIAO ESP32-S3 board with a built-in battery charger. Connected to it are: a ring of 12 LEDs, a digital microphone, a gesture sensor, a motion sensor and a small display.

The day the off-the-shelf software got thrown out
The plan had two stages: first WLED, a popular ready-made program for driving LEDs, and my own code only if WLED turned out not to be enough. It was enough for one day. It does not support the gesture sensor or the motion sensor without writing your own add-ons, and that was half the idea. Since the lighting modes had already been worked out in the simulator, writing my own firmware came out cheaper than adapting and reworking someone else’s.
Three traps in one sensor
The APDS-9960 gesture sensor shines invisible infrared light and measures how much of it bounces back off a hand. Setting it up properly and debugging it took the most time, and for three different reasons.
- A jumper you have to know about. The module has a solder jumper marked PS. If it is not bridged, the infrared LED gets no power. The sensor then answers correctly and looks healthy, except the proximity reading shows zero. You cannot tell this from the symptoms.
- A ready-made function, but no answer. The gesture-reading function spins in a loop until it has emptied the buffer. With the LED on, the signal never fades, so the loop never ended. The device answered on the network but would not serve the page. What helped was my own read routine, which goes through the buffer only once.
- A sensor that blinds itself. The LED inside the module shines partly straight into its own receiver, which gives a constant reading of about 145 units with nothing in the field of view. So a gesture has to be counted as the excess above the background, not as an absolute value. Otherwise the sensor keeps reporting some gesture that never happened (a false positive).
Even with those fixes the gestures came out at random. By the end of the day they were switched off as unusable, and a simpler interaction stayed in their place: covering the sensor with a hand – a cheap version of a capacitive touch sensor.

Two units, worlds apart in signal
A few days later, after the circuit was rebuilt, a second unit of the same module ended up in the base. The gestures started working. The cause was neither the code nor the settings.
The numbers explained everything. The first module gave a reflection off a hand of 10–16 units with noise of ±9, so the signal barely poked above the interference. The second gave 150–880 units with noise of 12–32. It is the same type of module, yet the reflection off a hand was roughly ten to several dozen times stronger in the second one.
The takeaway for anyone building something similar: thresholds for sensors like this are set for the specific unit. After swapping the module you have to measure them again. And a second thing, written down in the project documents in so many words: on the workbench, in a tangle of wires, gesture detection is a lottery. It has to be tuned only once it is closed up in the enclosure, with a window and empty space above the sensor.
The current budget: the charger lost to my own device
This is the most interesting moment of the whole project. The symptom looked like this: an hour and a half on the cable gave only 17% charge according to the battery indicator, and turning off the ring’s LEDs changed nothing. The device works that percentage out from the cell voltage, so it is an approximation, not a measured amount of charge.
Plain arithmetic explained it:
| Item | Current |
|---|---|
| The charger built into the board supplies | about 100 mA |
| The chip with its Wi-Fi radio constantly on standby draws | 80–120 mA |
| Display | 10–20 mA |
| Sensors and microphone | about 15 mA |
The electronics alone were eating as much as the charger supplies, or more – only the leftovers reached the battery. The biggest consumer was not the LEDs but the radio of the Wi-Fi chip, kept on standby without a break.
The same cause produced a second, misleading symptom. The device recognised a connected cable by the battery voltage going up. When the charging current equalled the draw, the voltage stood still, so the firmware reported “running on battery” with the cable plugged in.
The fix was to put the radio to sleep between transmissions. The saving came to 60–90 mA, which by the arithmetic means roughly twice as long a glow from the 1350 mAh battery. That is an estimate, not a measured glow time. The cost of putting the radio to sleep was measured: the panel’s functions on the phone respond with a delay of 11–26 ms when reading and 24–89 ms when dragging a slider – and a person does not notice that.
There is one limitation that cannot be worked around. The XIAO board’s 100 mA charger needs about 13 hours to fully charge a battery like this, even if the device drew nothing. The rough estimate from the start of the project, made before the radio was put to sleep, was 3–6 hours of glow on a single charge with calm effects.
How much longer will it glow?
The simple sum “capacity divided by current” says nothing about a specific brightness and a specific mode. So the device works out the remaining time differently: it watches how fast its own voltage has been dropping over the last five minutes and converts that into the time left until the battery protection threshold (3.35 V, at which point the LEDs go out).
An estimate from a single reading was off many times over, because the voltage of a lithium battery drops slowly in the middle of the discharge and quickly at the ends. Accuracy has its price: after a change of brightness the estimate needs a few minutes to settle.



A gift is not the same thing as your own toy
The last batch of changes was about how to hand the device over to somebody else. A “Forget WiFi network” function appeared in the panel. It erases the saved network and, on top of that, blocks the one that was written into the firmware for the duration of the build.
Without that block, the base in its new home would keep looking for the old network and would never put up its own, the one through which you set up Wi-Fi from a phone. The person receiving it would get a device with no way to get in and set it up.
The small display plays a similar role. It is not decoration: it shows the address where the panel lives, which previously could only be found by scanning the network. By default it sleeps, because a lit little screen next to the glass spoils the effect and uses power, and it wakes up when the base is shaken or the sensor is covered.

What this project says about working with an agent
- An agent cannot wave a hand. Telling a hand apart from an object placed nearby relies on the fact that a hand trembles and an object stays still. The threshold for that distinction was picked from a model, not measured, because there was no way to shake a hand in front of the sensor remotely.
- Numbers beat intuition. The charging problem was solved by a table with four rows, not by yet another fix in the firmware.
- Hardware can contradict the code. The gestures “didn’t work” for several days, and the culprit was the particular sensor unit. No change in the firmware would have fixed that.
- It is worth writing down what was left untidied. The last two changes in the project add no features. One makes the status of the connection to the home automation system be shown truthfully, the other records that after the board was swapped a duplicate device entry was left in the system.
A simple gift turned into more than three weeks of learning about sensors and power. If I had to point to one thing to remember, it would be the table of currents.
Before you start hunting for a bug, it is worth working out whether the device has any right at all to behave the way you expect.
Firmware for a glowing ESP32-S3 base for a block of glass: LED control, sensor gestures, battery measurement and a connection to the home automation system.




Leave a comment