detection of switch state in AC circuit

I am interested in detecting the state of a toggle (on/off) switch in an AC circuit. I have an idea for this design (described below), and I would like to know if this is workable, and the pros and cons of this approach. I have several projects for which I need to make a similar detection, so I would like to use this in other cases also.

My house is heated by “forced air with natural gas”. The basic control circuit runs on 24 VAC. A schematic of the basic thermostat circuit is attached. In a normal heat cycle, when the thermostat (switch) closes the gas valve opens. The gas is ignited by a pilot light, and the bonnet warms. Soon thereafter a relay turns on a 110 VAC motor which drives a squirrel cage fan which distributes the heat throughout the house. The thermostat is a “set back” type which turns the heat down at night and up during the day. If the house is cold, such as when the heat first comes on in the morning, after the gas has been on for some time the bonnet may reach an “over temp” condition. This is a normal condition of heating systems such as this one. When this condition occurs, a temperature switch in the bonnet (which is in series with the thermostat switch) opens. This causes the gas valve to turn off the gas. The bonnet cools as the fan continues to run. When the bonnet cools sufficiently the bonnet switch closes, and the gas value turns the gas on again. This cycle repeats until the thermostat switch opens when the house is up to the temperature set at the thermostat.

I want to measure the number and duration of the “over temp” cycles that occur. This means that I need to know when the bonnet switch opens and closes.

The gas valve operates on 24 VAC and draws up to 500 mA according to the data plate.. For convenience in making the measurements I want to make as few wiring changes as possible. I want to install the wiring that is shown by dashed lines in the attached schematic. I would like to place this wiring change at the bonnet switch, but it is much easier to put it at the thermostat, and I think that either placement will provide the information I want. The basic idea is that the Arduino will detect 2 things: (1) when there is a 24 VAC potential across the thermostat switch (I will call this the Arduino “switch detection” part of the circuit), and (2) when current is flowing in the thermostat circuit.

The detection for current flowing in the circuit is made with a DIY current detector that I made. It is able to detect current flow in the milliamp range, but not micro amps. This part of the design is working and I have no questions about it.

The switch detection circuit implements a voltage divider across the thermostat switch. The resistances are chosen so as to allow no more than 0.1 mA to flow in the thermostat circuit, and feed the Arduino analog input pin with peak voltage between 0 and about 4 volts. The 100 uA is intended to be way less than what is required to operate the gas valve, and also less than what the current detector is able to detect. The circuit includes a diode in order to block negative voltage to the AI pin. The arduino code samples the A0 analog input pin for current detection, and the A1 analog input pin for the switch detection. The switch detection is done by a loop that reads the AI pin for 500 ms and averages sum-of-squares the readings.

When the thermostat switch is closed the average will be 0, and it will be non-zero when the switch is open. Similarly, the current detection will be 0 when the gas valve is off, and non-zero when it is on. When the house is “at temperature”, the thermostat switch will be open, and the bonnet switch will be in its normally closed position. In this state there is 24 VAC across the thermostat switch, and micro amps, but not milli amps of current flowing. When the gas is on, the thermostat switch will be closed, and the bonnet switch will be closed. In this state there will be 0 VAC across the thermostat switch, and milliamps of current flowing. When the bonnet switch opens (the over temp condition), the thermostat switch will be closed (there will be 0 VAC across the thermostat switch), and there will be no milli amps of current flowing. With these measurements the Arduino can detect and report the number and duration of the over temp cycles. The circuit conditions are summarized as follows:

thermostat current
switch detection conclusion


non-0 volts 0 mA house is at temp
0 volts non-0 mA gas is on
0 volts 0 mA bonnet switch is open (over temp)
non-0 volts non-0 mA not possible

Will this switch detection design work?

switchDetector.pdf (23.6 KB)

Your overall circuit might be more complex (the current detector circuit is not shown) than using a few of these.

Here's an example that might work. It provides opto-isolation to the Arduino.
Note: Configure your digital inputs with INPUT_PULLUP.

You could need a reverse diode across the LEDs to bypass the reverse 24v as it is AC. Most LEDS have a small reverse voltage tolerance.

Weedpharma

But the MID400 is a AC opto coupler :wink:

You can also use a (cheap and easy to get) DC opto coupler (lik PC817). Then you do need a anti-parallel diode across the opto and I would add a little RC filter (aka, add a pull up resistor and a capacitor).

Another simple solution would be to add two relays and use that.

Even a direct connection is possible. Connect the thermostat 24VAC to the Arduino 5V. Connect the two switch terminals via a diode and a resistor to the Arduino. And I would add a capacitor to make it DC. It's not a isolated solution but the most simple :slight_smile:

Thanks for the suggestions.
According to the data sheet for the MID400, it is designed for monitoring line current and specifies a minimum of 90 VAC. My thermostat circuit is only 24 VAC, so I don't think this device will work.

Also, as I mentioned, without a lot of work I only have access to the connections at the thermostat. So I would only be able to install a MID400 like device at the thermostat, not at the bonnet sensor.

septillion suggests using a relay, but I don't think that will work as it would be added in series with the gas valve and probably prevent it from operating.

I didn't include the details of the current detector because it is in and working. FYI, I made it by making a double wrapping with about 100 loops each of #24 wire around a 2" diameter washer with a 3/4" hole. This was an experiment and it worked, so I didn't try to refine it. One of the wrappings is the primary and the other is the secondary. It has a 50 ohm burden resistor. For the secondary circuit I used a voltage divider and added about 1.5v DC to the circuit in order to raise the AC above 0 for the Arduino input. I did not calibrate it because for this application I only care if current is flowing, or not. The arduino sampling works great. In the setup routine I sample the input for 500 ms (30 complete cycles) and take the average. This gives me the dc offset to subtract during the monitoring phase. Anyway, this part of the circuit is irrelevant to my switch state detection question.

What I really want to know is if the simple switch detection circuit that I posted has any hope of working? While other devices might also work (e.g. something like the MID400, but for lower voltage), I want to know if the proposed design will work. I have never tried something like this before, are there any seriously bad side effects that I should be aware of?

The 90VAC minimum is for Rin = 22K. If you change Rin to 4.7K, it will work for 24VAC as it will power the IRLEDs on the emitter with about the same current.

Yes, your circuit might work , but I would make sure that the max current that would ever flow through any input connection to the Arduino is limited to <= 1mA. This will ensure that the MCU's internal protection diodes can successfully handle any overvoltage condition.

I'm not sure why you would need to measure current, unless you're just detecting its presence. Alternatively, you could just detect presence of voltage at each switch to determine if the gas valve is on.

I would think just using 100K resistors series connected to Arduino digital inputs (to monitor presence of voltage) and connecting Arduino's GND to the gas valve 24VAC transformer connection point would work. I would also use something like 470K to gently pull each input to GND when there is no voltage present.

Connect it to a rectifier parllel to the load and feed it as a gate signal to a rellay and use rellay as a switch in reading the signal

Your bonnet should never overheat if there is sufficient air flow. Either an air leak, dirty filter, fan speed too slow or just bad design. My 2 cents worth.

Paul

cdj15:
If the house is cold, such as when the heat first comes on in the morning, after the gas has been on for some time the bonnet may reach an “over temp” condition. This is a normal condition of heating systems such as this one.

Absolutely not normal. This is an indication of a leaking heat exchanger. Very dangerous because in addition to overheating the cold side of the heat exchanger, it means you are blowing carbon monoxide into the house. You didn't say which model furnace you have, but if it's a Goodman-Janitrol, I'll put money on my hunch.

A linear Hall Sensor (as opposed to switch) should be able to detect field around a single wire.

cdj15:
I am interested in detecting the state of a toggle (on/off) switch in an AC circuit.

Try this non invasive circuit.