How to detect 24VAC as 5VDC input for microcontroller?

Thread Starter

AverageMoss

Joined Apr 24, 2021
8
Hello, I'm working on a little side project for my home thermostat.

I recently bought a nest smart thermostat to replace my old "dumb" thermostat and ran into an issue with the wires. I don't have enough wires to accommodate all of the thermostat functions. Running new wiring is not an option because that means cutting open a lot of drywall but there is a product called the FAST-STAT wire extender that uses data communication with a transmitter/receiver setup (transmitter wired to thermostat and receiver wired to furnace).

The catch is that this product is very expensive. So I decided it would be interesting to come up with my own version of this with two microcontrollers communicating via serial connection.

The concept is a three wire connection between transmitter and receiver. R-wire is 24vac, C-wire is common, and third wire is data wire. Both transmitter and receiver will be powered by the R and C wires.

The problem I'm stuck on is that the transmitter will receive 24vac inputs from the thermostat that I then need to convert to 5vdc for the microcontroller. There will be a total of 8 inputs coming from the thermostat and more than one can be energized at the same time.

I will already have a rectifier circuit connected to R and C wires to power the board, I just need some way to detect if there is 24vac on any of the inputs then send 5vdc to the inputs on the microcontroller. The simpler the circuit, the better since I would like it to be as compact as I can get it and be somewhat cost effective.
 

Dodgydave

Joined Jun 22, 2012
10,592
You can monitor the AC wires for 50/60 Hz signal by using optocouplers, to create a signal that the micro can detect.
 

ronsimpson

Joined Oct 7, 2019
2,540
Why not to use a resistive divider let the output is 5V??
We don't know how the AC and DC are isolated or connected. The DC ground probably has nothing to do with the AC.
There is a slight chance one lead of the AC is the same as "ground" but which lead.
Best to assume there is an unknown and changing connection or total isolation requiring an opto isolator.
 

Thread Starter

AverageMoss

Joined Apr 24, 2021
8
We don't know how the AC and DC are isolated or connected. The DC ground probably has nothing to do with the AC.
There is a slight chance one lead of the AC is the same as "ground" but which lead.
Best to assume there is an unknown and changing connection or total isolation requiring an opto isolator.
I know how to use an opto isolator to control high voltage AC with low voltage DC, but how do I do it in reverse? Control low voltage DC with high Voltage AC.
 

MaxHeadRoom

Joined Jul 18, 2013
26,337
Again, you could take a leaf out of the Opto22 range, they have AC & DC modules for I/O (both directions).
The racks they fit on are universal for all the different types. Example circuit below for sensing AC which could be easy to reproduce.

e.g. HV AC input modules,
1667487478088.png
 

panic mode

Joined Oct 10, 2011
2,366
the schematics clearly shows what to do....


if you use an AC optocoupler, you do not need a bridge.
to limit current in the input circuit you need to use a resistor.
say 10mA input current is good enough to drive LED in optocoupler, and Vf is 1.4V. if using bridge then add 2x 0.7V to that.
then series resistor could be chosen and would be in the neighborhood of 2k2 and at least 1/4W (preferably 1/2W).
then the transistor in the optocoupler can be connected to 5V with some load resistor. depending on CTR of the opto this can be 1-10k. choose larger value if not sure and you are done.
 

Phil-S

Joined Dec 4, 2015
231
Broadcom do ICs specifically for AC mains to DC logic in their HCPL series.
An electricians solution might be to use an RF link like RF Solutions Mains Link.
It would interesting to hear just what the extra functions of the Nest are that need more wiring.
Most room thermostats either have a permanent live and a switched live and if you are lucky a neutral as well.
I've been told that some electricians use the earth of the cable as an extra connection but I'm not advocating that solution.
 

rphare

Joined Nov 20, 2015
11
Opto22 devices are straightforward but a bit pricey for a home project (~$30.00 on each end per signal).
Consider miniature relays, at least on the 24V input side.
 
Two capacitors (rated for higher voltage) from each one of AC lines to a bridge rectifier with a large three resistor (1M+) divider as a load. Make the input caps just large enough to supply enough current for the divider to make 24VDC. Take the middle resistor's negative output to the uC ground, positive clamped to the uC rails with a pair of diodes and capacitor to the uC ground for steady digital signal onto the input pin. So far, three caps, three resistors, six diodes (three if you use something like dual BAS101S). Failure (short) of either input cap will produce small current through the clamping diodes or into uC ground, not enough to fry anything (that's why you want three large resistors in the divider). Figure out the time constant for the capacitor charge/discharge timing - can't be that important for slow signaling you are accommodating.
 

Hemi

Joined Mar 17, 2012
28
Below is portion of a circuit I designed a few years ago to detect whether my furnace is on or off:
1667610243323.png

C1 is a 50V rated electrolytic cap. R1 and R2 are little 1/8W resistors. HVAC-SENSE is connected to the microcontroller. I'm using my micro's internal weak pullup to keep the pin high while the furnace is off (you could use a third resistor tied to your 5VDC). When the furnace turns on, the opto (U1) will pull the pin low. So it's reverse logic, but simple, cheap design. Hope this helps.
 

conciseusa

Joined Dec 13, 2019
2

Attachments

Top