# Automation Hat mini - AC Voltage

Hi,

I’ve just bought an Automation Hat Mini and I’m loving it. I’m currently using it to read the voltage going to the buzzer in my intercom and then using the relay to buzz open the door.

I’m currently having some trouble reading the voltage though. My multimeter reads a steady 1.4ish volts (AC) when in an inactive state and 3.3ish when the bell is rang. Using the ADC input (A1) on the mini though, I’m getting values that fluctuate heavily, which means I can’t use a simple `if voltage > 3V then` statement. Test output below:

``````2020-11-15 08:47:18 - voltages - INFO - 5.33
2020-11-15 08:47:19 - voltages - INFO - 1.1
2020-11-15 08:47:19 - voltages - INFO - 13.5
2020-11-15 08:47:19 - voltages - INFO - -1.24
2020-11-15 08:47:19 - voltages - INFO - -0.91
2020-11-15 08:47:19 - voltages - INFO - -0.99
2020-11-15 08:47:19 - voltages - INFO - -2.26
2020-11-15 08:47:19 - voltages - INFO - -1.22
2020-11-15 08:47:19 - voltages - INFO - -2.29
2020-11-15 08:47:20 - voltages - INFO - 0.28
2020-11-15 08:47:20 - voltages - INFO - 24.64
2020-11-15 08:47:20 - voltages - INFO - 28.93
2020-11-15 08:47:20 - voltages - INFO - -0.74
2020-11-15 08:47:20 - voltages - INFO - -2.02
2020-11-15 08:47:20 - voltages - INFO - -1.21
2020-11-15 08:47:20 - voltages - INFO - -1.27
2020-11-15 08:47:21 - voltages - INFO - -2.21
2020-11-15 08:47:21 - voltages - INFO - 29.89
2020-11-15 08:47:21 - voltages - INFO - -2.29
``````

Does anyone have any ideas what might be causing this result? Is it because the input is AC voltage instead of DC?

Thanks for any help!

Reading some more about AC/DC (I’m relatively new to electrical engineering :) ), it is, in fact, very bad to use AC voltage in an ADC input. Learn something every day!

So my follow-up question is: are there any ready-made off-the-shelf solutions that can convert the AC signal to DC, or will I have to build something myself?

A diode will get you a DC voltage. If you get the polarity correct it will block negative voltages and pass only positive. The DC voltage will be roughly half what the AC is.
A bridge rectifier will do it too, and give you a better DC voltage.
Just wire the two ~ terminals to the AC source, - to ground and the + to the ADC.

1 Like

Thanks for the solution @alphanumeric! It was actually your reply to an earlier thread that made me realize I was doing it wrong. So thank you two times.

The resultant DC voltage is going to have a lot of ripple on it, so your readings are still going to fluctuate around some. They should be all positive readings though. A filter capacitor on the output, the + and - will flatten it out. It will also slow down the respose to a change on the input side. There will be a delay while the capacitor discharges.

Thanks again for that information! Saved me a second trip to the electronics store.
If found a nice breakout board that supposedly does what I would want it to do from Numato, but unfortunately they don’t seem to make it anymore.

Nonetheless, the documentation gives a pretty good feel of what I’d need to build.

That’s pretty well what you want to build. An old style power supply minus the step down transformer.

I just got round to ordering the parts from Digikey, ended up picking up another possible solution as well.
With the help of a friend, I figured out that I might as well sense current instead of voltage. So I picked up the ACS723 as well. It will likely have the same issue as the bridge rectifier (the ripple), but I’ll see how it does. :)

I’ll report back when I have 'em both set up.

Yeah, in the computer world its either a High 1, or Low 0. As far as the Pi’s GPIO goes anyway. AC voltage or current really messes things up, logic wise. And detection wise.