My recent SONOFF WiFi Switch experience reminded me of something from high school. I attended an off-site electronics class with my best friend. As teenage boys, we were prone to doing stupid things. One of our favorite games was to see who could handle the highest voltage. Our bench had a variable AC supply that went from 0 to 120 volts. So we would grab the alligator clips while the other person slowly turned the knob up. John once made it to 50 volts. I seem to recall my tolerance around 30 volts. First, DO NOT do this. It was stupid. Second, I think this game is why handling AC makes me so uncomfortable.
While I am not an electrician, I do know the basics about wiring mains AC circuits. So when one of my studio lights needed a new switch, I was okay to replace it. Mains AC does not scare me when it is off. I did not have a mechanical switch available. Instead, I opted for a SONOFF WiFi Switch. I did not intend to connect WiFi, at least not yet. I just wanted to control the light with the manual push button.
The clever solution seemed to be clever, at least for a few minutes. Suddenly the light turned off. I thought maybe there was a timeout for the manual button. Annoying, but workable. The lamp remained off for about another 2 minutes when I started to smell that unmistakeable burning plastic odor. Touching the case of the SONOFF identified the culprit immediately.
Great. So I have an AC mains switch that isn’t working, but I do not want to go poking my multimeter into it. What do I do?
Turns out, that SONOFF module was defective. I wanted to debug it, but I did not want to measure anything while connected to AC. Here’s how I used a thermal camera to debug my SONOFF.
What is a SONOFF?

SONOFF Board Backside 1600px
The SONOFF WiFi switch is an inexpensive AC relay. Internally it has an ESP12 chip, which became popular with the ESP8266. There is even an unpopulatd serial header which can be used to reflash the firmware. Among hackers, these modules are a popular way to get an AC relay that is easily programmed.
The Dilemma
Because time was critical, I just hardwired the lamp and threw the SONOFF aside. Yesterday I had some time before leaving on a business trip and got back to thinking about the module. Was it a fluke or was the module supposed to get that hot? If there was a short, why didn’t the AC circuit breaker trip? Also, is there really an ESP8266 inside of these things?
The problem is that I do not like taking measurements on AC. So after disassembling the board, I visually inspected it, but saw no issues. I did not see any shorts. I did not see any burned components. After shorting the two electrolytic caps, I knew it was reasonably safe to poke around the board with my Mooshimeter.
There wasn’t a short on the AC input or output, so that explains why there wasn’t a circuit breaker fault. By the way, I gave it a light scrub with alcohol to remove any flux residue. That step didn’t help. From there, I was not sure where to start. I did, however, see the distinctive in-situ PCB antenna and Espressif Systems SoC.
Thermal View
That is when I remembered I have a Flir One Thermal Camera attachment for smartphones. (They are selling the Gen 3 as of this post, I have an earlier version.) Until now, I have only used it to verify my HVAC was not working, and my 3d printer’s stepper motors got hot.
I pointed the camera at the PCB, plugged it in and saw this happen.

SONOFF Thermal Runaway
That area of the board got hot and fast. It was a simple NCP1117 linear regulator. I am not sure, but I believe it was a 3.3 volt output. The camera showed over 110°C on both sides of the PCB in that area. So either the SONOFF’s design sucks or something is wrong. At least now I had a place to start poking probes, while the board is unplugged.

NCP117 at 114C
I found that there was only a 33 ohm impedance between the NCP1117’s output and ground. You know the adage, “when you only know how to use a hammer, everything looks like a nail?” Well, I suspected the 470uF 16V electrolytic capacitor on the regulator’s output. I desoldered it and to my surprise! It was fine. In fact, my meter measured 500uF. Now I am not sure if the meter is off or if the cap is higher than rated, but still within tolerance. Either way, its leakage current was relatively low. So that capacitor is in good shape. Also, the 33 ohm impedance remained after removing the cap.

Cap is Cold
The other neon-red clue the capacitor was probably okay is the thermal picture from the other side. The big bright dot is the top of the capacitor. While its outside edge is heating up, the core is not.
Need a known good SONOFF
At this point, I had two choices: either start probing the board live or compare to a known good module. Luckily, when ordering cheap junk, I always order two. (My favorite quote from the movie “Contact” is “Why build one, when you can have two for twice the price?”) I added a cable, plugged it in and noticed two spots that heat up: the linear regulator and the ESP12 chip.

Good SONOFF Thermal Turn On
Now the key difference here is that both spots reach steady state between 30 and 40°C. Significantly less than what I saw with the other module. Also, the heat is limited to the two local heat sources. While this single data point does not let me state “this one works correctly,” it is behaving differently. For this comparison, let’s call this the “good module.”
Comparing the two modules, it appeared that spots on the boards heated up at about the same time. Which means, I couldn’t use just the thermal images to identify a short circuit. The fact that the heat-up patterns are about the same, combined with not finding a failed passive component, I am now suspecting the linear regulator itself.
Conclusion
I did not have time to replace the NCP1117. I elected not to remove it all because I do not have a replacement. But, my next step is removing the regulator to see if there is still a 33 ohm impedance on that voltage rail. If I am careful enough, I should be able to put it back in case I am wrong.
Debugging with a thermal camera allowed me to check various points on the circuit, identify potentially faulty components, and never once did I have to touch anything while this unprotected board was connected to AC mains voltages.
What else should I check? Have you had issues with these SONOFF modules? What tips do you have for debugging AC circuits safely?

