I want to create a small project with an ESP8266 that makes a server call when a thermostat is open or closed. My main problem is detecting the thermostat status.

The electro-mechanical thermostat has two wires going to it, one 220V line and a return line. When closed, the switch passes 200mA 20mA through it, to keep a relay closed. There is no neutral line available. I don't have access to the relay.

For safety and legal reasons I want to have the ESP8266 battery-powered. I could be smart and "leech off" current but charging a battery once a month is not that bad. I also want the detection to be isolated and non-contact, if possible.

One thing I could do is: add a kind of light indicator and use a light sensor to detect that. Not sure if I could make it light in the on-state, but should be straightforward to do for the off-state, with a resistor, LED and diode.

I don't have enough place inside the thermostat housing for a complicated circuit and I want to keep the ESP8266 module outside the thermostat housing, as a clip-on solution.

TL;DR: an easy non-contact way of detecting whether there is mains voltage without a neutral wire, to read by ADC or digital logic.

Edit: Inside one of the thermostats there is a neutral wire available. I guess with a little digging the other one has it as well. The available space inside the thermostat is around 20x20x20mm, so a module like TSP-03 would not fit.

I might switch the scope of the project from contactless to low-voltage, since it's a bit more reliable and easier to use. The idea is to provide two pins, that either have a voltage difference or close a contact (optocoupler). Whatever choice, it has to fit inside that enclosure and provide a safe output.

Edit2: FYI: The relay is in a remote location (fuse box) and triggers a 3-Phase heating element. No use going that route, even if I could. The uploaded picture shows the insides of the thermostat. The available space is on the left side.

inside the thermostat

The outside dimensions are 65x65x30mm. Another solution would be to completely replace the thermostat with another model that provides WiFi or access to the signal.

A very comprehensive discussion about a similar topic can be found here: https://www.raspberrypi.org/forums/viewtopic.php?f=45&t=9617&start=25 as well as throughout StackOverflow. I've read most of those.

  • \$\begingroup\$ if the contact is open then there is a voltage drop across it. If it is closed then there isn't... \$\endgroup\$ – ratchet freak Sep 16 '17 at 16:42
  • 1
    \$\begingroup\$ Why not just use another relay. The coil would be 240, and you would pull-up the contact to whatever voltage you want. And detect the contact closure. \$\endgroup\$ – mkeith Sep 16 '17 at 16:42
  • \$\begingroup\$ The light indicator is also a good solution. There are 220V AC indicators, you can assemble one of these in a black plastic box with a LDR (light dependent resistor) to create a kind of optocoupler. It will light when the thermostat is opened giving you low LDR resistance and when the thermostat is closed your LDR's resistance will be high. The response time is slower (1-2 sec.) than the relay (10-20 ms) and current transformer (0-10 ms), but depending on the process it may be acceptable. This is the cheapest solution. \$\endgroup\$ – Todor Simeonov Sep 16 '17 at 17:25
  • \$\begingroup\$ What about this? instructables.com/id/Contactless-AC-Detector \$\endgroup\$ – brainwash Sep 16 '17 at 20:08
  • \$\begingroup\$ Response time is ok, the thermostat actuates every 1-30 minutes, so anything under one minute is ok. \$\endgroup\$ – brainwash Sep 16 '17 at 20:10

If the current passing through the thermostat is AC i.e. 50 or 60 Hz then you could use a small clamp-on current transformer. The current flow will produce a voltage output across a burden resistor and this can be simply amplified to generate a "detect_current" signal.

If the current is DC then use a hall-effect sensor (which you could still use if the current is AC) but it's costlier and a little more tricky sometimes.

  • \$\begingroup\$ Current is AC. Perhaps something like an antenna? \$\endgroup\$ – brainwash Sep 16 '17 at 20:11
  • \$\begingroup\$ Well, an electric field antenna won't work because, at quarter of a wavelength it will be hundreds of km long. A magnetic loop antenna would work but, guess what, a current transformer in this application is basically that but up real close. \$\endgroup\$ – Andy aka Sep 16 '17 at 20:29

You could perhaps use a hall sensor to detect the magnetic field of the relay.

  • \$\begingroup\$ I don't have access to the relay, it's in a separate location. \$\endgroup\$ – brainwash Sep 16 '17 at 20:05

You could use something like this (connected in series with the thermostat contact). BR1 can be a 1A bridge. C1 something like 1000uF/6.3v. R1 is chosen so that the 200mA current provides a 5V drop from R1 in parallel with the relay coil resistance.


simulate this circuit – Schematic created using CircuitLab

You could use an optoisolator instead of the mechanical relay. There is plenty of current and enough voltage. Reduce R1 to 30 ohms and put a 130 ohm resistor in series with the LED. You can use something cheap like a 4N35.

R1 will need to be rated at 2W. If the relay current does not turn out to be exactly 200mA you may need to adjust the value of R1.

Edit: You have revised the problem description by reducing the relay current from 200mA to 20mA. That is still enough to operate a low current relay, such as the V23026D1021B201 or an optoisolator. Modify the value of R1 appropriately, and C1 can be reduced to 220uF or so.

  • \$\begingroup\$ I don't have access to relay, it's hardwired inside the house. The thermostat just closes a contact that triggers the relay contact. \$\endgroup\$ – brainwash Sep 17 '17 at 0:42
  • \$\begingroup\$ You put the above circuit in series with the thermostat contact. There is no need to have access to the relay. It steals a bit of voltage from the 230VAC relay to operate the 5V relay. \$\endgroup\$ – Spehro Pefhany Sep 17 '17 at 3:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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