Debug SONOFF AC Relay with a Thermal Camera

Find the problem without a live measurement


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

See the ESP8266 and Antenna?

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.

Continue Reading »

Supplyframe Hardware has published a video of a talk I gave in July 2017. This talk was at HDDG 22. The focus of my discussion was how an oscilloscope’s trigger circuit works. I built on that and talked about some of the behind-the-scenes stuff of what is going on with a digital oscilloscope. (You can download my HDDG 22 slides here.)

During #22 of the Hardware Developers Didactic Galactic meetup, I discussed Oscilloscopes. (Previously James talked about capacitors.) In the presentation, I broke down the internals of an oscilloscope. The presentation started off with a block diagram. Then I discussed the main components: vertical amplifier, A/D, memory controller, some of the computer side stuff, and the keynote was on triggering.

The trigger circuit of an oscilloscope fascinated me since very early in my HP/Agilent career. When I saw trigger modes like Pulse, Violation, Rise Time, and “Runt,” I thought: Wow, this must be the most complicated circuit in the scope! While it isn’t trivial, it very clever how just a few pieces of (relatively) simple hardware drive one of the most important aspects of a digital scope.

Download Slides

Rick Altherr also gave an excellent talk on ECUs and their sensors. (I always thought ECU only meant engine control unit. His talk helped me understand why that isn’t really the case anymore!) It was great to learn about the combination of the engine mechanics with the electronics that control it. !)

See Rick’s Slides

Mooshimeter Review – Smartphone Multimeter

Can your phone replace your DMM?

Mooshimeter Review

For fifteen years I used my Radio Shack 22-168A digital multimeter as my go-to meter. A couple of years ago I bought a Fluke 115. Not because the RS meter lacked a measurement, but because I wanted a backlit screen. Here’s the crazy thing though in 20 years of multimeter development, there hasn’t been much innovation. Well outside of maybe auto-ranging.

All three meters I have, plus the Virtual Bench I reviewed about a year ago all continue to have the same limitation: they can only perform one measurement at a time. That’s one feature that makes my latest meter, the Mooshimeter, unique. It can measure both voltage and current at the same time. Oh, and it doesn’t have a screen.

Continue Reading »

Logic Analyzer Tutorial and Introduction

Want to know if you need a Logic Analyzer?

logic analyzer introduction

A DMM, or multimeter, is the go-to instrument for debugging most circuits. You probably already have at least one DMM on your bench for this reason. Me? I have three. But that’s a different story. Let’s talk about a Logic Analyzer.

Digital signals represent two states: on (usually “1”) and off (usually “0”). A multimeter (DMM) may be of limited value for these signals. When using the DC voltage measurement, you can see “something” is happening, but not exactly what that “something” is. For example on a PWM pin, you’ll see the RMS Voltage change as you modify the duty cycle. However, you can not see if the signal is “ringing” when turning on and off.

For debugging digital signals, a popular option is to use a Logic Analyzer. If you are not familiar with a logic analyzer, or you are not sure if you need one, this tutorial should help.

First I’ll give a simple overview of what a Logic Analyzer does, some considerations when to use one, and then give some terms to know when looking at them.

Continue Reading »

Benchmarking Arduino’s digitalWrite() with a Logic Analyzer

Just how fast is digitalWrite()?

digitalWrite with Logic and Arduino Uno

Recently I picked up a device called Logic from Saleae. It’s a 4-channel USB-based logic analyzer. While learning how the simple, but effective, UI works I ran some timing benchmarks on my Arduino Uno. The subject? digitalWrite(). I wanted to know how fastdigitalWrite() could turn on two (or more) pins.

Almost all Arduino users start out with the simple “blink” sketch. Turn pin 13 ON, delay, turn it OFF, and delay again. The heart of this version of “Hello World!” is the digitalWrite() function. Many Arduino users never even think about all of the stuff this single function call hides.

In this post, let’s compare the speed of digitalWrite() to direct port manipulation, using a logic analyzer.

Continue Reading »