TEMP SENSOR CALIBRATION

Hello everyone,I am newbie in Programming.I trying to develop code for my needs.I need to read two analog sensors(Pressure,Temp) and monitor values via Serial Plotter,manage to connect two sensor readings at same plot,but need to calibrate temp sensor to show correct temp.

I use temp sensor wich can measure temp from 0-150C,sensor resistance 25C=221R, 50*C=245R,temp sensor supply 5V trought 250R. Also if possible to scale Y axis to see much clear graph beacuse need pressure from 0-4bar.

Picture show room temp. then heat with flame

Thanks in advance,for help

int input = A1; //connected to analog pin A0
int output;
int led = 2;
double temperature;
void setup() {
  Serial.begin(9600); // Communication speed
  pinMode(13, OUTPUT);
}

void loop() {
  output = analogRead(input);
  temperature = thermistor(output);
  Serial.print("Raw output: "); Serial.print(output);
  Serial.print("   Temperature, C: "); Serial.println(temperature);

  if (temperature > 30)  {
    digitalWrite(13, HIGH);
  }
  else {
    digitalWrite(13, LOW);
  }
  int sensorVal = analogRead(A0);
  Serial.print("Sensor Value: ");
  Serial.print(sensorVal);

  float voltage = (sensorVal * 5.0) / 1024.0;
  Serial.print("Volts: ");
  Serial.print(voltage);

  float pressure_pascal = (3.0 * ((float)voltage - 0.62)) * 1000000.0;
  float pressure_bar = pressure_pascal / 10e5;
  Serial.print("Pressure = ");
  Serial.print(pressure_bar);
  Serial.println(" bars");
  Serial.print("Pressure = ");
  delay(1000); // Slow down the output for easier reading
}

double thermistor(int RawADC) {  //Function to perform the fancy math of the Steinhart-Hart equation
  double temperature;
  temperature = log(((10240000 / RawADC) - 10000));
  temperature = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * temperature * temperature )) * temperature );
  temperature = temperature - 273.15;              // Convert Kelvin to Celsius
  //temperature = (temperature * 9.0)/ 5.0 + 32.0; // Celsius to Fahrenheit - comment out this line if you need Celsius
  return temperature;
}

Arduino_Thermistor-Press-bar_v2.ino (1.57 KB)

You can put the sensor in boiling water to get a reading on the high end value (212F) you can put the sensor in ice water (32F) to get the low reading value, and then you can use those values to define your sensors curve.

245ohm@50C sounds like a car oil/water temp sensor (thermistor).
If so, then returned A/D values are not linear with temp, so just calibrating at 0C and 100C won't work.
Might have to use a Steinhart-Hart equation.

Can't see your code. Please post according to the forum guidelines.
Leo..

You may try these 2-point calibration philosophy (assume linear sensor):

Given:
A(250C, 221R) ==> A(250C, 2.35V) //(5V221R)/(250R + 221R) = 2.35V
B(500C, 245R) ==> B(250C, 2.47V) //(5V
221R)/(250R + 245R) = 2.47V
C(T0C, R) ==> C(T0C, V)

(50-25)/(2.47-2.35) = (T-25)/(V-2.35)
==> T = 208.3*V - 464.58

Codes:

analogReferece(INTERNAL); //1.1V
float T = 208.33*(1.1/1023)*analogRead(sensorPin) - 464.58;
Serial.print(T, 2); //T is in degree centigrade with 2-digit after decimal point

Verification:
(1) Put the sensor in a beaker of normal water. Check the reading -- should be close to 400C.
(2) Put the sensor in a beaker of boiling water. Check the reading -- should be close to 1000C.

hello, I made sensor test

205R-2.190V=5*C

214R-2.100V= 20*C

235R-2.300V= 40*C

248R-2.336V= 50*C

252R-2.440V= 70*C

268R-2.500V= 90*C

276R-2.573V= 100*C

AcoVukovic10:
hello, I made sensor test

Is it real test or mathematical?

real test I perform

The resistance doesn't change very much - what is your circuit?

AcoVukovic10:
real test I perform

Please, post your codes and calibration factors: gain and offset. What test bench have you used for test purposes?

I put sensor in water and make measuring voltage and resistance. I use 5V supply and resistor 250R voltage divider

int input = A1; //connected to analog pin A0
int output;
int led = 2;
double temperature;
void setup() {
  Serial.begin(9600); // Communication speed
  pinMode(13, OUTPUT);
}

void loop() {
  output = analogRead(input);
  temperature = thermistor(output);
  Serial.print(output);
  Serial.print("   Temperature, C: "); Serial.println(temperature);

  if (temperature > 30)  {
    digitalWrite(13, HIGH);
  }
  else {
    digitalWrite(13, LOW);
  }
  int sensorVal = analogRead(A0);
  Serial.print("Sensor Value: ");
  Serial.print(sensorVal);

  float voltage = (sensorVal * 5.0) / 1024.0;
  Serial.print("Volts: ");
  Serial.print(voltage);

  float pressure_pascal = (3.0 * ((float)voltage - 0.62)) * 1000000.0;
  float pressure_bar = pressure_pascal / 10e5;
  Serial.print("Pressure = ");
  Serial.print(pressure_bar);
  Serial.println(" bars");
  Serial.print("Pressure = ");
  delay(1000); // Slow down the output for easier reading
}

int input = A1; //connected to analog pin A0
int output;
int led = 2;
double temperature;
void setup() {
  Serial.begin(9600); // Communication speed
  pinMode(13, OUTPUT);
}

void loop() {
  output = analogRead(input);
  temperature = thermistor(output);
  Serial.print("Raw output: "); Serial.print(output);
  Serial.print("   Temperature, C: "); Serial.println(temperature);

  if (temperature > 30)  {
    digitalWrite(13, HIGH);
  }
  else {
    digitalWrite(13, LOW);
  }
  int sensorVal = analogRead(A0);
  Serial.print("Sensor Value: ");
  Serial.print(sensorVal);

  float voltage = (sensorVal * 5.0) / 1024.0;
  Serial.print("Volts: ");
  Serial.print(voltage);

  float pressure_pascal = (3.0 * ((float)voltage - 0.62)) * 1000000.0;
  float pressure_bar = pressure_pascal / 10e5;
  Serial.print("Pressure = ");
  Serial.print(pressure_bar);
  Serial.println(" bars");
  Serial.print("Pressure = ");
  delay(1000); // Slow down the output for easier reading
}

double thermistor(int RawADC) {  //Function to perform the fancy math of the Steinhart-Hart equation
  double temperature;
  temperature = log(((10240000 / RawADC) - 10000));
  temperature = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * temperature * temperature )) * temperature );
  temperature = temperature - 273.15;              // Convert Kelvin to Celsius
  //temperature = (temperature * 9.0)/ 5.0 + 32.0; // Celsius to Fahrenheit - comment out this line if you need Celsius
  return temperature;
}