Hi,
i have a problem with measuring 12V DC. I haven't found answer at any other forum, so I hope you will help me.
I have connected switched-mode power supply 15V/1A with parallel catalytic 22uF and foil capacitor 330n then 7812 in order to decrease voltage to stable 12V and stabilize signal with catalytic 10uF and foil 100n. The voltage measured by multimeter is 11.72V which is okay for me.
Anyway when I measure it with analog pin (a0-a5) of Arduino uno (and 2 other plates similar to it) of course via voltage divider (10k and 20k, 47k and 68k) readings are between 0 and 5V (varying without any reason).
The same situation occurs when applying 9V DC from a battery.
I think it's not because of the supply, but there might be some problems with arudino, however, should I apply anything to my loop? Or connect any different pin to Arduino, such as reference pin or sth?
About schematic: Resistor after diode is 100Ohms to measure voltage drop (current), voltage divider is made of resistor 47k and 68k that should give numbers between 0 and 4,9V (fine for Arduino), potentiometer is 5k, capacitors as written earlier.
Simplified code (just to measure voltage at output from potentiometer to check if it is working):
What does that mean? If you've made a 30K & 115K voltage divider it should be OK.
You need a common ground between the Arduino and the voltage you're measuring. The Arduino measures relative to it's ground. I'd guess you're missing the connection so there's no reference and the input is "floating" relative to Arduino ground.
When troubleshooting, it's a good idea to simplify things and just check the raw ADC reading. There could be an error in your voltage calculation (although if the reading is stable the voltage calculation will also be stable).
Well, if you would be so kind you can check, I've already added schematic and code; everything is fine when measuring voltages from Arduino or via potentiometer up to 5V, problems become when I plug in other power supply (with higher voltages).
When it comes to divider I just count it, when you use R1=to 68k and R2=47k the maximum voltage is 47/(47+68) *max Voltage, which for 12V would be around 4,9V
(same with 10k and 20k if max is 12V, max after divider will be 4,00V)
I don't have actually any connection between Arduino gnd and power supply. So shall I simply connect and pin with gnd on power supply (meaning after all "stabilizers")?
Other than sharing grounds, you should use the internal voltage reference for this kind of measurement. Use a voltage divider to bring down the voltage to <1.1V.
For accurate measurements, calibrate as there's quite a tolerance to this reference voltage, but it's very stable. The 5V Vcc against which you reference by default is not guaranteed stable, but can easily be 4.5V or so.
All of the grounds should be connected together. I'm pretty sure that's the problem.
FYI - That's NOT a schematic. A schematic shows the electrical connections & "symbolic" components without regard to their physical arrangement or physical appearance.
For those of us with electronics experience, a schematic is a LOT easier to follow & understand.
It does create the possibility of the actual circuit not matching the schematic, but that can happen with your pictorial diagram too.
Which will require a different voltage divider and different calculation. ...And that's not the problem at the moment.