← Back to projects

TENS Game Unit

December 17, 2025

View GitHub repo
TENS Game Unit

I used UART communication, OpenCV, and GPIO pins from the ESP32 to interface with an off-the-shelf TENS unit to administer a shock upon detection of a downed state in-game.

The Origins of this Project

I'm going to ask you to suspend any questions regarding my mental wellbeing until the end of this post, as I want to talk more about the journey of why I wanted to work on this project in the first place. I had recently gotten familiar with using electronic lab tools outside of school projects, and I had an interesting realization; "testing" circuits in a laboratory setting makes zero sense when the instructor already knows what the output is.

On another note, I have hit zero improvements in Apex Legends, a game I often play. It's gone far enough to the point where I can't even call it a learning plateau; it's almost as if I have reached my peak (a peak that has stretched for thousands of miles).

With both of this in mind, I had an amazing thought. Intrinsic incentive to improve in video games is difficult. If I want to improve, I can't just sit down and try my hardest; I need an extrinsic motivator.

The Actual work

As a safety precaution, TENS units don't allow you immediately shock people with a single button. You have to slowly ramp up the intensity to your desired strength. This makes sense because ordinary people are using these machines for pain relief, not as a mock shock collar.

initial TENS Unit
The first prototype. Scrapped because of the mess of wires.

To work around this, I immediately thought of bypassing the physical button interface with a digital one via GPIO pins. The entire system would be a camera detection system sending serial data to an ESP32, which would then interface with the TENS unit through a PWM signal that immediately ramps up the intensity.

Since I didn't want to trigger the Anti-Cheat software of Apex (as easy as it is to bypass), I settled with using OBS to capture a cropped section of my screen, which I would read through a Python script. This script would also use OpenCV to detect the red lines that appear around the character symbol upon being downed. As a confession, I haven't studied computer vision for more than 30 minutes, so this type of detection was entirely carried by whatever Gemini spat out.

Figuring out which traces on the PCB corresponded to which inputs/outputs was the most rewarding aspect of the project. This might be crazy, but it turns out that the visible traces seen on PCBs aren't an arbitrary artistic design; they are genuine electrical connections. Using this information, combined with an excess of bravery, the ground/power pins from the battery, and a multimeter, I managed to intuit that the pins were active low. This, combined with the impedance measurements I did, allowed me to program the pins as no-pull outputs, making the system flawless in design.

Final Thoughts

If I were to come back to this project, I would start with looking deeply in the anti-cheat software to see if I can integrate the screen capturing and serial output into one file for the ease of the user (me). Some twisted part of me also wants to design a TENS unit from scratch so that I don't have to deal with a mess of wires whenever I want to set the machine up, but I still value my life enough to not use myself as a testing ground.

As a final aside, if you're inspired by the project and want to ask me any questions, this paragraph is a polite rejection. I take zero responsibility for any twisted ideas that come out of this design; I cannot financially or emotionally handle the potential fallout.