# How to calculate this circuit

Hello, I have a question on you guys. I want to measure a negative voltage with my arduino. I found one circuit on the internet and I simulated the circuit in Microcap to find values of resistors, which would be suitable for my project.

Here it is: Circuit

It works fine, I measured some voltage levels with my multimeter and then I made a graph in excel to see if it measures correctly - see Graph. On the y axis are measured analog values and on the x axis is voltage.

But the problem is that I can’t figure out a way how to calculate the right values of the voltage from the measured values. I would be grateful for any advice…

If you only want to measure negative voltages, then remove the resistor to ground. It reduces the A/D range (lower resolution), and it's only needed if you also want to measure positive voltages.

Not sure about the code to convert A/D value to voltage. I would first flip the A/D range with the map function, like this.

val = map(val, 1023, 0, 0, 1023);

Then subtract an A/D offset value that would be there when the input of the divider is connected to 0volt (ground). Then multiply the remainder with a value that results in displaying the right negative voltage.

But there might be more clever ways to do this. Leo..

Just looking at the graph, you take the Y value, which you have got as an analog value, and multiply it by 0.03. You then subtract 17 from it. That gives the voltage on your X axis. (Approximate values by inspection).

Volts = ( analogRead() * 0.03 ) - 13.0

Use floats for the calculation. Didn’t Excel give you a formula like Y = m * X + c ?