Maker Pro
Maker Pro

easier way for a 5Vdc mcu to check a 120Vac switch

vitroblue

Jan 2, 2013
4
Joined
Jan 2, 2013
Messages
4
what would be the cheapest way for my 5Vdc mcu to check if a 120Vac switch is open or closed?
is there any way i can avoid a transformer and a rectifier bridge? i'm not gonna drag current... and i cannot change the switch
i thought of zeners, transistors, resitor voltage divisors...
but i'd like to protect my mcu, so is it wise to use an optocoupler?

can anyone gimme some suggestions?

thanks
 

pwdixon

Oct 14, 2012
52
Joined
Oct 14, 2012
Messages
52
If the switch has two sets of contacts perhaps you could use the non-mains side of the switch.

You could use an opto-coupler to isolate the mains from your processor just have to be careful/clever about thermal management.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
An optocoupler is the safe way due to its isolation.
Assuming your optocoupler requires 5mA, you need a series resistor of 120V/5mA=24kOhm. Note that voltage and current are effective (RMS) values. Your peak voltage will be 170 V, your peak current 7mA. You will need a diode antiparallel to the optocoupler's diode to protect the LED from reverse voltage.
The series resistor will dissipate P=I^2*R=0.6W.

Here is a page that explains LED operation from mains. The capacitor used there reduces the power dissipation by acting as a reactive resistance.

Note that your µC will see a square waveform including logic LOW levels even if the switch is on. This is due to the sinusoidal waveform of the mains AC. You need to filter the signal (e.g. look for edges within one mains interval 16ms...20ms, depending on your mains frequency).

Harald
 
Top