Problem with code oil pressure and temp sensor

Hi,
I would like to do an arduino project which would read data from three sensors and display the data on the LCD screen.
The sensors are: boost pressure, oil pressure, oil temperature.
I dealt with the boost pressure quickly because it works linearly and the other two don't.
Here is the data for the two sensors I got from the manufacturer:
(The data is "ready" after selecting the appropriate resistors.)

From this I have determined the function formulas

all data:

And here I stopped.
I have too little knowledge and can't write code using these functions. And the information from the Internet doesn't tell me much :confused:
Could someone help me, suggest something in writing the code for these two sensors?

It's not clear to me which is your request.

You would like calculate the value of Y starting from X (which I assume to be the value from sensors)?

I wouldn't use those functions in the Arduino itself. Instead, I would create a table with a limited number of values pre-calculated from those functions and use interpolation to fill in the gaps.

For example, you could enter those equations into Excel and generate a table of, say, 33 entries for voltages starting at 0 and incrementing by 0.15625V up to 5V:

const float cgrOilPressure[] PROGMEM =
{
    0.0,            //000
    0.139921181,    //020
    -0.046322741,   //040
    -0.097551793,   //060
    -0.035057538,   //080
    0.119702226,    //0A0
    0.345708762,    //0C0
    0.622987686,    //0E0
    0.933214267,    //100
    1.260318718,    //120
    1.591091497,    //140
    1.915788599,    //160
    2.228736851,    //180
    2.528939211,    //1A0
    2.820680063,    //1C0
    3.11413051,     //1E0
    3.425953671,    //200
    3.779909978,    //220
    4.207462472,    //240
    4.748382095,    //260
    5.451352991,    //280
    6.374577796,    //2A0
    7.586382938,    //2C0
    9.165823932,    //2E0
    11.20329067,    //300
    13.80111274,    //320
    17.07416467,    //340
    21.15047128,    //360
    26.17181297,    //380
    32.29433096,    //3A0
    39.68913265,    //3C0
    48.5428969,     //3E0
    59.05847929     //400   

};

(Note the values were copied directly from Excel; no need for that many decimals tbh...)

The value 0.15625V was used for a specific reason. For a 5V reference and a 10-bit ADC (0x000 to 0x3FF counts inclusive), 0x15625V represents 32 ADC counts (that is: 0.15265/5.0 * 1024 == 32). This means that the entries in the table represent a value 32 ADC counts higher than the previous entry.

Consider the 10-bit value coming back from the ADC. The count would go:

0b000 0000 0000     0x000
0b000 0010 0000     0x020
0b000 0100 0000     0x040
0b000 0110 0000     0x060
.
.
.
0b011 1110 0000     0x3E0
0b100 0000 0000     0x400   <-- not actually used; just frames the end of the table

We can actually index into that table using the upper 5 bits of the ADC result. This also means we have 5 bits in the ADC result (able to range from 0x00 to 0x1f) "between" entries into the table and we can use a linear method to interpolate between two adjacent points in the table.

For example, suppose the ADC result came back at as 0x2A2:

0x2A2 == 0b1010100010
0b1010100010
  |||||
  +++++ upper five bits gives index into table; here 15h or 21d

0b1010100010
       |||||
       +++++
- lower 5 bits give "fractional remainder"; here 2h (2d)

The fractional remainder can range from 0b00000 (00h) to 0b11111 (1Fh). On that next ADC tick, we get to the next entry in the table and the remainder count goes back to 00h.

In the example of 0x2A2, we are looking at the 21st entry into the table and the remainder is 2; the fraction is 2/32 or 0.0625 of the way to the next entry in the table.

If we look at the table we see the value there is 6.374577796 and the next value is 7.586382938.

The difference between the next and the current is 7.586382938 - 6.374577796 or 1.211805142.

If we multiply that value by our fractional remainder of 0.0625 we get 0.07574... We can add that value to the 21st entry in the table to get an interpolated value of 6.4503...

Here's an example in use:

#include <avr/pgmspace.h>

const float cgrOilPressure[] PROGMEM =
{
    0.0,            //000   0
    0.139921181,    //020   1
    -0.046322741,   //040   2
    -0.097551793,   //060   3
    -0.035057538,   //080   4
    0.119702226,    //0A0   5
    0.345708762,    //0C0   6
    0.622987686,    //0E0   7
    0.933214267,    //100   8
    1.260318718,    //120   9
    1.591091497,    //140   10
    1.915788599,    //160   11
    2.228736851,    //180   12
    2.528939211,    //1A0   13
    2.820680063,    //1C0   14
    3.11413051,     //1E0   15
    3.425953671,    //200   16
    3.779909978,    //220   17
    4.207462472,    //240   18
    4.748382095,    //260   19
    5.451352991,    //280   20
    6.374577796,    //2A0   21
    7.586382938,    //2C0   22
    9.165823932,    //2E0   23
    11.20329067,    //300   24
    13.80111274,    //320   25
    17.07416467,    //340   26
    21.15047128,    //360   27
    26.17181297,    //380   28
    32.29433096,    //3A0   29
    39.68913265,    //3C0   30
    48.5428969,     //3E0   31
    59.05847929     //400   32

};

const uint8_t pinOilPressure;

void setup() 
{
    Serial.begin(115200);
    pinMode( pinOilPressure, INPUT );
    
}//setup

void loop() 
{    
    uint16_t valOP = analogRead( pinOilPressure );        
    
    Serial.print( "ADC : " ); Serial.print( valOP, HEX ); 
    Serial.write( '\t'); 
    Serial.print( "Oil Press.: " ); Serial.println( fInterp( valOP, cgrOilPressure ) , 4 );
    delay(250);
 
}//loop

float fInterp( uint16_t counts, const float *fTable )
{
    uint8_t
        idx = (uint8_t)(counts >> 5);
    uint8_t
        interp = (uint8_t)counts & 0x1f;
    
    float v1 = pgm_read_float( fTable + idx );
    float v2 = pgm_read_float( fTable + idx + 1 );
    
    return (v1 + (((v2 - v1) * (float)interp) / (float)32));
    
}//fInterp

This generates the following with A0 connected to 3.3V on the Mega:

ADC : 2A1	Oil Press.: 6.4124
ADC : 2A2	Oil Press.: 6.4503
ADC : 2A2	Oil Press.: 6.4503
ADC : 2A2	Oil Press.: 6.4503
ADC : 2A1	Oil Press.: 6.4124
ADC : 2A2	Oil Press.: 6.4503
ADC : 2A3	Oil Press.: 6.4882
ADC : 2A3	Oil Press.: 6.4882
ADC : 2A2	Oil Press.: 6.4503

Using canned-data and interpolation is how auto manufacturers do it (well, when I was reverse engineering PCMs back in the 1990s that's how they did it, when computing speed and memory were very low). In those days they'd use fixed-point math; there was no need for 4 or more decimal places; I used floats here because it's easy and the processor is reasonably quick. YMMV.