I'm working on a project to better understand how my home cooling system behaves. I'd like to produce graphs of temperature in various areas, overlaid with when my existing thermostat turns the A/C compressor and fan on.

Connecting up a few ESP8266's with temperature sensors reporting over WiFi is straightforward enough; I'm comfortable doing that. But I'm struggling with how to detect when my thermostat is calling for A/C cooling.

My (battery-powered) thermostat has red, white, yellow, and green wires:

  • Red has ~28Vac
  • White enables the heating system
  • Green enables the fan
  • Yellow enables the A/C compressor

With a multimeter, I easily determined that the thermostat simply closes a relay (I can hear it; that was a dead giveaway) and there's no resistance. So if A/C is called for, it closes relays connected Red to Yellow (and Green).

I don't really want to mess with drawing power from the 28Vac; it's easy enough to power an 8266 with 5V from a wall wart and that's sufficient for this project. Ugly, but acceptable.

I want to detect when the thermostat relay is closed and turning on the air conditioner. Clearly I'm not an EE by trade, and I'm struggling with the right search terms to communicate "detect whether two outside pins are electrically connected". I think something that emulates a multimeter's continuity function would work.

I did find references to the LM*39 series, but (1) I'm not sure it would like being exposed to AC power, and (2) the 'offset voltage' is usually measured in mV, which suggests to me that I'm barking up the wrong tree.

  • If there are 3 relays, and you know that the relays control the 3 'systems', then you could wire up your 8266 through the "NC" (not connected) pin then you know that when voltage goes through the NC pin the relay is not on
    – Coder9390
    Aug 5, 2021 at 0:51
  • The easiest way probably is to connect to the 28V signal and measure it. 28V is not high enough to be dangerous to humans, but it is dangerous to your ESP8266, but it's very simple to decrease the voltage to a level where your ESP8266 can safely detect it. Aug 5, 2021 at 9:39

2 Answers 2


Welcome! I used bidirectional optocouplers. The input has a resistor I believe 27K and the output is a NPN transistor with a pull up to +5. The emitter goes to electronic ground. I connected these across the relay coils. They have not given me any problems since installed about 15 years ago. Nice thing they are not polarity sensitive.

enter image description here

  • heh i guess opto couplers are the way to go if you don't already have a bunch of op amps. +1 to that
    – Abel
    Aug 5, 2021 at 3:43
  • I used them because of the electronics in the HVAC system is AC and needed to stay isolated from the rest of the world. Thanks Able
    – Gil
    Aug 5, 2021 at 4:49
  • Thank you! I’ll try this.
    – cwright
    Aug 7, 2021 at 18:49
  • You are welcome, let us know how it works out.
    – Gil
    Aug 8, 2021 at 2:00

Most straight forward method should be to slap an op amp on the leg of the wire that the relay activates and deactivates by connecting to it. The key is to power the op amp with low voltage so your esp gets that as input. The signal legs can handle whatever the relay gives, and the ac, fan, and heater will handle the pull signal for the not connected state.

That only goes so far as to protect the esp by having the op amp take the high voltage and output low. To turn a potentially AC low voltage signal into a nice dc one, use a diode, capacitor, and resistor (trim pot). Remember that this is going to be discharging that cap through your resistor so figure out a minimum and check the pot before powering the device (or add a regular resistor in series).

  • Sending a high voltage input to an op-amp powered by a lower voltage isn't necessarily safe for the op-amp. You'd have to check the datasheet for the specific op-amp. Better to use a voltage divider to reduce the voltage. Aug 5, 2021 at 9:41
  • remember to check specs regardless of what components. if you are using a voltage divider- figure out acceptable current losses and the wattage requirements for your resistors.
    – Abel
    Aug 8, 2021 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.