<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[yoyouv Engineering]]></title><description><![CDATA[Engineering articles on UVC LEDs, ESP32 control systems, UV water treatment, thermal design, sensors, and OEM UV system integration.]]></description><link>https://yoyouv.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6aa765101e3a861edd293d99/73bc0c52-9de9-4838-b31d-1290498aafb0.webp</url><title>yoyouv Engineering</title><link>https://yoyouv.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 03 Oct 2026 18:52:25 GMT</lastBuildDate><atom:link href="https://yoyouv.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Designing a Fail-Safe ESP32 Controller for a Flow-Through UVC LED System]]></title><description><![CDATA[ESP32 UVC LED Controller Architecture
An ESP32, a flow sensor, a temperature sensor, and a UVC LED driver sound like the ingredients for a fairly simple embedded project.
On paper, the logic is straig]]></description><link>https://yoyouv.hashnode.dev/https-yoyo-uv-com-blog-esp32-uvc-led-controller</link><guid isPermaLink="true">https://yoyouv.hashnode.dev/https-yoyo-uv-com-blog-esp32-uvc-led-controller</guid><category><![CDATA[ESP32]]></category><category><![CDATA[embedded systems]]></category><category><![CDATA[iot]]></category><category><![CDATA[Electronics]]></category><category><![CDATA[arduino]]></category><dc:creator><![CDATA[Kevin Pan]]></dc:creator><pubDate>Mon, 28 Sep 2026 02:48:47 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6aa765101e3a861edd293d99/2ebe87b2-f131-49f1-a013-fa185b28d803.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2><strong>ESP32 UVC LED Controller Architecture</strong></h2>
<p>An ESP32, a flow sensor, a temperature sensor, and a UVC LED driver sound like the ingredients for a fairly simple embedded project.</p>
<p>On paper, the logic is straightforward: detect water flow, check the temperature, and enable the UVC source when everything looks normal.</p>
<p>The interesting part starts when you ask what “normal” actually means.</p>
<p>A flow sensor can stop responding. A temperature sensor can disappear from the bus. The water can move too slowly or too quickly. A driver may expect a different enable voltage from the ESP32. And a system that powers up in the wrong state can create a problem before the firmware has even finished initializing.</p>
<p>That is why I think the control logic deserves as much attention as the UVC hardware itself.</p>
<h2><strong>Why Flow Sensor Voltage Compatibility Matters</strong></h2>
<p>The first thing I would check is voltage compatibility.</p>
<p>Many inexpensive Hall-effect flow sensors are powered from 5 V, and some produce output signals that can also rise toward 5 V. An ESP32, however, uses 3.3 V logic.</p>
<p>Those two facts should never be connected by assumption.</p>
<p>Before wiring the flow signal to a GPIO pin, check the actual sensor datasheet or measure the output. If the signal can exceed the ESP32’s allowed input level, use a suitable voltage divider, level shifter, transistor stage, or another appropriate interface.</p>
<p>This sounds obvious, but it is one of those details that is easy to miss when a prototype is assembled quickly on a workbench.</p>
<p>Espressif’s own hardware documentation is worth checking whenever there is uncertainty about GPIO voltage limits.</p>
<h2><strong>Using a DS18B20 for UVC LED Temperature Monitoring</strong></h2>
<p>A DS18B20 is a convenient choice for monitoring temperature because it is inexpensive, easy to integrate, and only requires one data line.</p>
<p>There are two details I would not skip.</p>
<p>First, the 1-Wire data line needs the appropriate pull-up resistor. The common arrangement uses roughly 4.7 kΩ between the data line and 3.3 V.</p>
<p>Second, the temperature reported by the sensor is only the temperature where the sensor is mounted.</p>
<p>If the DS18B20 is attached to a heat sink, it is measuring the heat sink. If it is mounted near the LED PCB, it is measuring that area. It is not directly measuring the LED junction temperature.</p>
<p>That matters when deciding on a shutdown threshold.</p>
<p>A value such as 60°C might be useful during prototype development, but it should not become a universal limit copied from one project to another. The real threshold depends on the LED module, PCB, drive current, heat sink, ambient temperature, and the position of the sensor.</p>
<h2><strong>Why Water Flow Rate Matters in UVC Treatment</strong></h2>
<p>The simplest possible controller only asks one question:</p>
<p>Is there flow?</p>
<p>For a flow-through <a href="https://yoyo-uv.com/uv-lights-water-treatment/">UVC system</a>, I would ask two:</p>
<p>Is the flow high enough?</p>
<p>And is it still below the maximum operating range?</p>
<p>The first condition prevents the UVC source from operating when water is stationary or barely moving.</p>
<p>The second is just as important.</p>
<p>As flow through a fixed chamber increases, the water normally spends less time inside that chamber. That means a system should not automatically treat every non-zero flow rate as acceptable.</p>
<p>This does not mean the ESP32 can determine whether the water is microbiologically safe. It cannot.</p>
<p>The maximum acceptable flow has to come from the design and validation of the complete UV reactor.</p>
<p>What the controller can do is enforce the range that the system designer has already established.</p>
<h2><strong>How to Calibrate a Water Flow Sensor</strong></h2>
<p>Flow-sensor examples often contain one calibration value that gets copied from project to project.</p>
<p>I would avoid doing that.</p>
<p>Different sensors can produce very different numbers of pulses for the same volume of water. Even two units of the same inexpensive sensor may not behave exactly the same.</p>
<p>A better approach is surprisingly low-tech.</p>
<p>Run a known volume of water through the sensor, record the number of pulses, repeat the test several times, and calculate an average pulses-per-liter value.</p>
<p>That measured value becomes much more useful than a number taken from an unrelated tutorial.</p>
<p>If accurate flow measurement matters to the final product, calibration should also be checked at several flow rates rather than only at one point.</p>
<h2><strong>Designing Fail-Safe UVC LED Control Logic</strong></h2>
<p>One of the most useful design decisions is also one of the simplest:</p>
<p>The UVC output should start OFF.</p>
<p>When the ESP32 boots, resets, loses a sensor, or encounters an invalid condition, the controlled output should remain disabled until the system has enough information to justify enabling it.</p>
<p>I prefer thinking of this as permission rather than switching.</p>
<p>The controller is not asking, “Is there a reason to turn the UVC off?”</p>
<p>It is asking, “Do I currently have enough valid information to allow it to turn on?”</p>
<p>That small change in perspective produces better fault handling.</p>
<p>If the temperature sensor disappears, that is not an unknown temperature that can be ignored. It is a missing safety input.</p>
<p>If the flow signal disappears, the controller should not assume the water is still moving.</p>
<p>Unknown conditions should generally move the system toward the safer state.</p>
<h2><strong>Connecting the ESP32 to a UVC LED Driver</strong></h2>
<p>Sensors are noisy. Pumps start. Valves open. Flow rates fluctuate.</p>
<p>For that reason, I would not enable the UVC driver after the first measurement that happens to fall inside the acceptable range.</p>
<p>A short stability period is more useful.</p>
<p>For example, the controller can require two or three consecutive valid measurement cycles before allowing the output to turn on.</p>
<p>Faults should work differently.</p>
<p>If flow suddenly stops or the temperature crosses the shutdown limit, there is little reason to wait for several more samples before responding.</p>
<p>This leads to a control behavior I like for protective systems:</p>
<p><strong>Slow to enable, fast to disable.</strong></p>
<p>It is a simple idea, but it makes the controller much less twitchy around thresholds.</p>
<h2><strong>UVC LED Thermal Management and Temperature Limits</strong></h2>
<p>Another detail that deserves checking is the driver’s enable input.</p>
<p>An ESP32 GPIO should only control the enable pin directly if that pin is documented as compatible with 3.3 V logic.</p>
<p>Some drivers may need a transistor, MOSFET, optocoupler, or level interface.</p>
<p>And the microcontroller should never be treated as the LED power source.</p>
<p>A high-power UVC LED needs a suitable constant-current driver matched to the <a href="https://yoyo-uv.com/uv-led-modules/">LED module</a>‘s electrical requirements.</p>
<p>The ESP32’s job is to make decisions.</p>
<p>The driver’s job is to regulate LED current.</p>
<p>Keeping those responsibilities separate makes the hardware much easier to reason about.</p>
<h2><strong>UVC Control vs. Water Disinfection Validation</strong></h2>
<p>This distinction is probably the most important one in the whole project.</p>
<p>A controller can measure flow, watch temperature, detect faults, and manage the LED driver.</p>
<p>None of those things prove that a particular microbial reduction has been achieved.</p>
<p>UV water-treatment performance also depends on factors such as wavelength, optical radiant output, water UV transmittance, reactor geometry, flow distribution, exposure time, fouling, temperature, and the target microorganism.</p>
<p>That means an ESP32 prototype can demonstrate good control behavior while still saying nothing about whether the reactor delivers a validated UV dose.</p>
<p>Those are two separate engineering problems.</p>
<p>Keeping them separate also prevents a prototype from making claims that the hardware has not actually demonstrated.</p>
<h2><strong>How to Test the Controller Safely</strong></h2>
<p>Once the basic flow and temperature logic is working reliably, there are several useful directions to take the controller.</p>
<p>UV intensity monitoring would be near the top of my list. Driver-current feedback would also help detect electrical faults that a simple enable signal cannot see.</p>
<p>Other useful additions include leak detection, total treated-water volume, LED operating hours, data logging, a hardware watchdog, and an independent enclosure interlock.</p>
<p>At that point, the project becomes much more than an ESP32 turning a UVC LED on and off.</p>
<p>It becomes a small safety-oriented control system.</p>
<p>And that is the part I find most interesting: not how to switch the light source, but how to decide when the controller has enough trustworthy information to allow the system to operate.</p>
<h2><strong>Future Improvements</strong></h2>
<p>For the electrical side of the design, I recommend checking <a href="https://docs.espressif.com/projects/esp-faq/en/latest/hardware-related/hardware-design.html?utm_source=chatgpt.com">Espressif’s</a> official documentation on ESP32 GPIO voltage limits and the <a href="https://www.analog.com/media/en/technical-documentation/data-sheets/ds18b20.pdf?utm_source=chatgpt.com">Analog Devices</a> DS18B20 datasheet rather than relying only on hobby-project wiring diagrams.</p>
<p>Those two documents answer most of the basic questions about signal voltage and 1-Wire sensor wiring before the first prototype is powered.</p>
]]></content:encoded></item></channel></rss>