# Create Look Up Table for Linear Pressure Sensor

Hello Arduino-Community,

I'm trying to measure the Oil Pressure with a VDO compatible pressure probe.

It's range is from 0 - 10 bar. The resistence is from 3 - 160 Ohm. If I'm right, the resistence of the sensor is linear. Rising with pressure. It's wired up, with a voltage divider with a 200 Ohm Resistor. Can someone instruct me how to calculate the Lookup table?

Best regards Bastian

If I'm right, the resistence of the sensor is linear.

What if you are wrong? Can you provide a link to the data sheet for the sensor?

Unfortunately I dont have a datasheet, but several pages on the internet say, that the "VDO-Style" pressure probes are linear..

Then you don’t need a lookup table. If you measure the resistance of the sensor you can just calculate the pressure, or use the map() function.

..if linear you dont need a table. connections: GND ... sensor ...x.... 180 Ohm .. 5V Output (at x) to analog input. 3V3 to Aref input.

0 Bar ..> 3 Ohm will return reading (3/(180+3) -> 0,0819V -> analogRead value 25 10 Bar ..> 160 Ohm will return reading (160/(180+160) -> 2,3529V -> analogRead value 729

nearly good code: float p = 0,03477*float(analogRead(Ax))-0,3477

With R=200 the digits in formula changes to ...3373

Hello,

it seems that the sensor is not really linear. This is what i found:

``````Resistance
7,0 ,00 bar
11,6    ,25 bar
16,2    ,50 bar
20,7    ,75 bar
25,3    1,00 bar
29,9    1,25 bar
34,5    1,50 bar
39,0    1,75 bar
43,6    2,00 bar
48,2    2,25 bar
52,8    2,50 bar
57,3    2,75 bar
61,9    3,00 bar
66,5    3,25 bar
71,1    3,50 bar
75,6    3,75 bar
80,2    4,00 bar
84,8    4,25 bar
89,4    4,50 bar
93,9    4,75 bar
98,5    5,00 bar
103,1   5,25 bar
107,7   5,50 bar
112,2   5,75 bar
116,8   6,00 bar
121,4   6,25 bar
126,0   6,50 bar
130,5   6,75 bar
135,1   7,00 bar
139,7   7,25 bar
144,3   7,50 bar
148,8   7,75 bar
153,4   8,00 bar
158,0   8,25 bar
162,6   8,50 bar
167,1   8,75 bar
171,7   9,00 bar
176,3   9,25 bar
180,9   9,50 bar
185,4   9,75 bar
190,0   10,00 bar
``````

I don't know how to solve this problem... :( :( regards Bastian

It looks pretty linear, apart from the first few readings. After that bar ~= resistance /19.5. Do you need an accurate reading in the sub 1.5 bar range or is it enough for your purposes to say that the pressure is low?

(feed 5V, Aref 3,3V)

Readings from table are almost perfectly linear.
If this shall be correct its also important that 5V in fact is 5V (and 3V3 …)

knut, your way is not working.. or i made a mistake?.. :zipper_mouth_face: wildbill? I want to whole range 0 - 10 bar in 0.1 steps... I still don't know how to solve this.. :(

Be sure to connect like this: GND -> sensor -> analog in -> 200 Ohm -> 5V. now assuming 5V Aref

Then if zero P, (Rsensor=7 Ohm) -> Vin = 5V/207*7=0,1691V -> analogRead will return 34 ( =0,16*1023/5) inserting result (34) into formula P=34*0,02156-0,7459 = -0,01286 (zero)

If P=10Bar , (Rsensor=190 Ohm) -> Vin = 5V/390*190=2,4359V -> analogRead will return 498 again: inserting (498) into formula P=498*0,02156-0,7459 = 9,9911 (10 Bar)

.. and the sensor is linear. I cannot see anything wrong.. maybe important : declare variables float ! .. and when calculating - force float! 'overkill' example: __ float pressure=float(analogRead(Ax)) * 0.0nnnn - 0.nnnn ;__ Display with 1 decimal: Serial.print(pressure,1);

I am also looking into the possibility to use the exact same sensor. However, that table you have seems to be for another unit since the sensor is labeled 3-16 ohm, not 7-190 as in your table. My question is if you have any update on the specs and/or maybe a source of your data?

``````int x=analogRead(pinWhatever);
int vTimesTen=map(x,15,820,0,100);
int wholeBars=vTimesTen/10;
int barTenths=vTimesTen%10;
char pressureString[16];

sprintf(pressureString,"Pressure = %i.%i",wholeBars,barTenths);
Serial.print(pressureString);
``````