Measuring voltage

Hello,

I want to use my Arduino to measure the voltage of a (regulated) power supply to test the Arduino's accuracy (and my program). Can I simply connect the minus pin to an analog pin on the board and the plus to Arduino's GND? If so, would that impact the display and button I connected to the same GND pin? If it is of any relevance, the Arduino is powered via USB. Would that be safe? I'd love to try it myself, but as an electronics beginner I don't want to fry the chip or power supply.

Thanks a lot!

If you don't want to fry the chip (or anything generally speaking) don't connect a positive line to a GND (as you suggest below) as it will be a direct short.

This should be possible though but how you wire it will depend on the maximum output of your supply. What is it?

Also what are you planning on using to display the voltage? LCD / 7 segment / etc

The maximum output can be regulated and I wanted to test with voltages between 0V and 5V. I'm using a 16x2 LCD display with backlight, so it needs two connections to GND.

Can I simply connect the minus pin to an analog pin on the board and the plus to Arduino's GND?

The analog pins must never see a negative voltage.

So how would one connect that? I know now what not to do, but I can't find a simple way to bring all these things together. Where would I connect the positive/negative lines to? Would I need a resistor even if I only supply 0V-5V? Thanks!

The best information is in the micro-controler datasheet not in arduino website.. Have a look on it and you will see the you can not apply on a pin a voltage under -0.5V

If you are only going to be inputting a maximum of 5v then it should be safe to connect the output directly to the arduino’s analog pins (although a resistor between them wouldn’t hurt)

The pin (analog 0 in this example) can be read simply using this line of code …

``````int pinReading = analogRead(A0);
``````

You then need to convert that to a voltage as the reading will be a number between 0 and 1023 depending on where the voltage is sat on the range of 0-5v. For accuracy it is best to use a float …

``````float voltage = pinReading * (5.0 / 1023.0)
``````

You will then have a (hopefully) accurate reading of the voltage stored in the float “voltage” which you can then output to anything you want.

thermalhound: ``` float voltage = pinReading * (5.0 / 1023.0) ```