1-5V sensor calculations


Just to give you some back ground I've just started playing with arduinos in the last couple of weeks and so far really enjoying it!

currently I'm using an UNO R3 to log and maintain two long term pressure test we have in our workshop so we can minimise travel back and forth daily during this troubling period.

the uno is taking in pressure readings, logging them and it is also attached to a relay which actuates a solenoid when a certain pressure value is reached which vents off any excess pressure in the system (all of this is working great)

the issue I'm having is coding my sensor output values correctly,

I'm using a 1-5V 0-10 bar pressure sensor but at 0 volts it's reading 0 BAR when it should be reading -2ish bar

could someone please advise on the correct calcs required for this

sensor data sheet attached (please note I'm using these sensors as they tie in really nicely and simply to the test system



Hey mjw1994,

Please attach your code here. This is required for any kind of help...
I also think, you are multiplying the analogRead() result with a certain number and that results with 0... Therefore I guess your problem is more an arithmetical than software development kind. Still, I might be wrong and for that, we have to take a peek at your code :slight_smile:

Btw, how do you expect a 0-10 bar pressure sensor to return a -2 as pressure value?
And last of all... did you read the datasheet yourself? It says the initial value is 0 bar. So everything is working properly...


for reference I'm a mechanical engineer, so forgive me if i come across as completely electrically inept!!!

I did read the data sheet, the sensor has a 1-5v output signal so at 1v it reads 0bar and at 5 v it reads 10bar if the sensor breaks or becomes disconnected from the circuit a negative value is displayed on the log or readout as there is no voltage going to the analog input, in larger systems it's a way of easily identifying a instrument issue opposed to a mechanical issue if that makes sense!

ah as I'm new i may have posted this in the wrong place....

initially i was using a map to scale the sensor readings correctly but that wasn't displaying the fractional values so now I'm using the following:

float sensorValue = (analogRead(A1) / 1024);
// map it to the range of the analog out:
float outputValue = (analogRead(A1) / 1024.0 * 10.0);

hope this helps


Link says 1V for 0 bar, 5V for 10 bar, you need to subtract 1V from your ADC result before calculating, post your code.

Look up map() function.

Tom... :slight_smile:

I see. As you can see on

float outputValue = (analogRead(A1) / 1024.0 * 10.0);

if 0V comes in, analogRead(A1) is 0. 0/1024 * 10 = 0.

Therefore you see 0 Bar.

You can use map() or you can create a mathematical function in form of mx+b.

m = (ymax-ymin) / (xmax-xmin)
whereas your y = Bar (10- whatever your minimum is)
whereas your x = Voltage (5-1 V) or 5-0V