AC reading from Transformer

Hi to all and Happy New Year with Health
I am not sure if the title is right but couldn't think anything else

So i need to measure the state of 3 switches that are connected in series and are powered from a 110v Ac from a transformer

i thought that the easiest way to do was to rectifier the Ac to DC and then with a simple voltage divider drop the voltage to under 5v to measure it with my microcondroller

(i placed the values only to first voltage divider but are the same values and the other 2)

i placed also a Zener diode of 5v for extra protection to my microcontrellers pins

My problem with that setup :

if the first switch is NO (Normally Open) then i read zero with analog read to all 3 analog pins .

If now close (NC) the first switch and the 2 other continue to be NO then i am getting high values for my first analog pin but also getting lower values to the other 2 analog pins .
if i NC and the second switch then i am getting at the first and second analog pins the same high value but the third one that is NO i still getting the lower values

i used an if statement in my code to filter the lower values to display them as 0 and so i can use it.

But would like to know why i am getting the lower values and if i could add some other component or make it with different arrange so when i the first Switch is NC then the two others be at 0 or almost to 0

As i am using a lgt8f328p chip with 12Bit ADC my Analog read values when the switch is NC are fluctuating : from 2900 to 3800

the Values that i am getting to the pins when are NO fluctuating : from 1200 to 2400

( 12-Bit ADC max value = 4096 , 10-Bit ADC max value = 1024 )

Thanks in Advance

your schematic doesnt indicate anything else is connected to those switches - so why not use dc 5V?

I cant see that on your schematic.

the peak value of 110V rms is about 160V. Your divider drops that to 160*2.5/60 = 6.8V
So you may well be exceeding the input voltage for the analog pins.

a 5V zener diode will not provide that protection.

I'd suggest
1: you only need half wave rectification
2: you need to change the divider chain
3: you could use digital inputs
4: maybe opto-isolators?

Thanks for your reply

the switches / transformer are part from an existing old control panel and my schematic is an attempt to sneak a peek from a distance the state of the switches

Ok will make a new one with that approach

Ok

My first goal was to use digital inputs but as i was getting so fluctuating readings was not possible to have stable readings ( fluctuating also from 0 to 1 )

do you know any dip package opt-couplers suitable for what i need to do?
i am familiar with the sharp PC817 that i am using a lot to my circuits but is for dc small voltages

the time constant of your RC filter is only 25msec. Try bigger capacitors eg 47uF across 4k7 (220msec). and series resisitor of around 160k

A easiest solution is relays with 120VAC coils.

Almost any opto-isolator will work. The LED on the input, along with the current limiting resistor drops the voltage.

You do need a "power resistor". 120V x 10mA = 1.2 Watts.

And you need a reverse diode across the LED-input to kill the reverse voltage (before it kills the LED in the opto-isolator).

And of course, you'll get-out a pulse, not continuous DC.

Both of those solutions also isolate the Arduino from high voltage which is a bit safer than relying on a voltage divider.

Id agree ….A good simple way is to power relays from the switches or transformers in the panel and use the contacts as inputs .
You then have complete isolation from the panel to your Arduino .
You can get DIN mounting relays .
If you unsure of working with such electrics it’s simple for a sparkie to install the relays and bring out wires from the contacts .

1 Like

Thank you all for the kind effort to answer me

I decided to go with the Optocoupler solution. I find some PC814 Optocouplers (for AC) and i make my design to a Breadboard and worked fine

here is my Schematic for any one is interested (or had any suggestion on it as a more experienced in electronics )

i used the Analog pins but in my code i used them as Digital inputs

An AC source looks like this:

Thanks for the obvious mention , but the drawing program i used didn't had Ac power only DC power to import to my schematic .

fortunately the previous member didn't stuck with that and read my description to understand what kind of power was

post#7

Remove the 10k resistors.
Connect the opto transistor (and cap) between pin and ground.
Use the internal pull up of the ProMini
pinMode(pin, INPUT_PULLUP);
The pin is now 'normally high', and low with power on the opto.
Leo..

It's not obvious. We don't know your skill level. Read here for a while and find out what you will see. The correction is not just for you - it's for all the people who read the diagram here.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.