My toilet has a seat sensor and flushes automatically when I get up from the seat. If I use it standing up, I still have to press the flush button. Since the original remote sends commands over infrared, I thought I could put a little device next to the toilet. Hold a hand near it, pause for a moment, then pull it away to flush. I could leave the toilet itself untouched and keep using the original remote.
The first time it worked by the toilet, I was still holding a breadboard with jumper wires dangling from it. I went on to design a PCB, have a few boards made, and solder the components myself. Two wires on a pin header and a window a few millimeters wide in the 3D-printed enclosure ended up taking the most time.
First, I got an LED to light up with a wave
For the first prototype, I used an ESP32 and an APDS-9960 proximity sensor I already had. At power-up, I kept my hand out of the way for three seconds so the sensor could take a baseline reading. A valid gesture meant bringing a hand close, holding it there for about half a second, and moving it away within three seconds. Keeping the sensor covered would time out and cancel the gesture, so an object left near the sensor wouldn’t trigger a flush.
I checked the serial output for a valid gesture, then hooked up an LED and a resistor as a test load. Once the LED lit as expected, I brought the remote into the setup. Later, I switched to the smaller XIAO nRF52840 and moved the firmware to CircuitPython so I could update the Python files directly while debugging.

Sending infrared commands directly
My first idea was to wire an AQY212EH PhotoMOS relay across the two contacts of the remote’s flush button and have the microcontroller press it for me. The LED test went fine, but something odd happened when I connected the remote’s circuit board. With a normal press, the remote’s transmit indicator goes out almost immediately. With the PhotoMOS connected, it blinked for about ten seconds, as if the button were still held down. I even saw the same behavior with the PhotoMOS control side disconnected and only its output side wired to the remote. I never pinned down the cause, so I decided to capture the infrared signal directly.
I hooked up a TSOP38238 receiver and pressed the flush button on the original remote three times. The captured data bits matched in all three recordings. Each frame had 69 pulse and gap intervals, totaling about 66.6 milliseconds. I saved the duration of each interval and had the XIAO drive an IR transmitter module to replay the signal on a 38 kHz carrier. With the receiver next to the transmitter for a loopback test, I captured a complete frame and confirmed that the data matched. I also kept a backup of the waveform so I could reuse it if I switched boards.
On the first test by the toilet, the transmitter’s indicator lit up, but nothing happened. I swapped the 1 kΩ series resistor on the transmitter’s DAT line for a 330 Ω resistor, waved again, and finally heard the toilet flush. The close-range loopback had already picked up the waveform. This time I knew it could trigger a flush from where the device would actually sit.

That settled the design. The APDS senses proximity, the XIAO decides whether it’s a valid gesture, and a separate IR module sends the flush command. I could remove the receiver I’d used to capture the signal and keep using the original remote independently. The device runs on USB power and locks out for 60 seconds after sending a command to prevent back-to-back flushes. The green LED flashes rapidly to indicate that the command was sent. I still had to check whether the toilet responded.
Two problems in a row with the new PCB
I brought the wiring I’d already tested on the breadboard into KiCad and designed a 58 × 48 mm two-layer carrier board. The XIAO plugs into two rows of socket headers so it can be swapped out if it fails. The sensor and transmitter module each have their own connector, the 330 Ω resistor is on the board, and signals such as SDA and SCL have test points. While getting ready to order the boards, I found that the through-hole capacitors I’d chosen had a lead pitch of 5.08 mm. My first layout called for 2.50 mm. I adjusted the holes for all four capacitors, moved some silkscreen markings off the pads, and rechecked the electrical and layout rules, the exported Gerber files, and the drill files. I sent the corrected R2 files to the board house and soldered the components onto the bare boards when they arrived.


The red light came on as soon as I plugged the XIAO into the first board. I disconnected both external modules, enabled the microcontroller’s weak internal pull-ups, and took multimeter readings at the test points. SCL was at 3.27 V, while SDA was only at 0.37 V. I soldered just the two socket headers onto a second bare board and tested it with the same XIAO. Both lines pulled high. I never found the exact fault on the first board, so I carried on with the second.
With the sensor connected to the second board, I measured 3.3 V at the module, but an I²C scan still didn’t find 0x39. I switched off the power and used the multimeter’s continuity mode to trace the connections from the carrier board’s test points to the sensor’s solder pads. It turned out I’d swapped SCL and INT. I switched the wires back, the sensor showed up in the serial output, and the controller went into standby as expected after the startup lockout. The test points came in handy both times.
The printed enclosure gave the sensor trouble
The first enclosures snapped together, with a sensor window in front, a USB opening at the top, and the IR LED pointing down. I later made the enclosure thinner and tried to reuse the backplate I’d already printed. During assembly, I found that the female Dupont connectors and the bends in the wires took up more space than I’d allowed for in the model. I also had trouble lining up the USB opening and getting the plug to seat fully. Two rounds of reprinting ate up time and material. After that, I printed small test pieces with just the snap-fit slots and USB opening, and checked them against the actual parts.

When I powered it up again, the red and blue lights started alternating. I could read the APDS chip ID over the serial connection, but the log said something was obstructing the sensing area during calibration: the average of 40 samples was above 180. Back in the model, I found that the opening in the black insert was only 4.6 mm at its narrowest point. Even with the lens centered, there was only about 0.23 mm of clearance on each side. A small misalignment could block the optical path, and the edges of the hole might also reflect infrared light back toward the sensor. The window became the main suspect, though I hadn’t finished comparing readings with and without the enclosure.
For R8.1, I switched to an open mount. The three boards are spread out and held in place with zip ties, with nothing in front of the sensor or IR LED. The mount raises the sensor and moves the transmitter board farther out, leaving room to plug and unplug the Dupont connectors and for the wires to bend. The slicer estimated 8.39 grams of PETG for the mount, compared with about 43 grams for the complete R7.1 enclosure. I assembled the open mount and confirmed that the wave-to-flush function worked.

Getting the final build working
By late November, the XIAO-based flusher was working as intended. The gesture was the same one I’d first tested with the LED: bring a hand close, pause briefly, then pull it away. The toilet flushes and the controller locks out for a minute. With a USB power supply, it works without a computer connected.
Once it was working, I tried waking the controller with an interrupt from the APDS. Deep-sleep testing turned up another power issue. The power bank’s indicator was still on, but I measured 0 V at the module’s supply. Plugging it back into the computer restored power, and the device log recorded an undervoltage event. I suspect the power bank switches off under a light load. I haven’t measured the actual power savings or battery life yet.
Looking back, what sticks with me is standing by the toilet and hearing it flush after I put in that 330 Ω resistor. Designing the board, soldering it, tracing wires, and test-fitting the enclosure were all steps toward turning that breadboard with its dangling jumpers into something I could use every day with a quick wave.