How to make a map with analog in

Hello!

I would like to make a temperature sensor with lcd,unfortunatelly i bought a sensor but it doesnt have a datasheet only the range -40 +130c
Its an ntc temp sensor, at 25c ~2500ohm.
I made a voltage divider circuit to read ohms in analog input(read voltages and calculate resistance)
Other problem is that the sensor is not linear i can measure the resistance at the range of celsius ups.
I would like to make it work 0-100celsius.
My plan is that i make a map.
Problem is that i dont understand how to make .
Any1 could help me with this problem?

Thanks Ricsi!

The most straight forward approach would be to create an array of 1024 elements since that is the resolution of an arduino A2D and then fill it in with the celsius value for the given voltage. With that, you read the analog pin, look up the value in the array and get the corresponding temperature.

You could also model the relationship with some sort of equation and avoid the large array, but that might be more work depending on how linear/non-linear it is and how much accuracy you desire.

The Steinhart-Hart formula works well for many NTC temperature sensors. Arduino tutorial.

You need to measure the resistance value of your sensor at 3 temperatures, and that will allow you to determine the constants needed. Here is one example of a calculator for the constants.

The sensor is definetly non linear sonetimes 50ohm/celsius sometimes 20 assoon as possible i will check the stwinhart formula!
But if that formula is not good for me can you guys help me how can i make an array or some kind of temp/map
Map?

Please study the material linked in reply #2 carefully.

Hello!

I think after studying the links,i made the circuit and the code. And its seems to work!
As soon as possible i will make measurements for accurate steinhart readings and equations!
Thanks Guys!
One more question,this average thing doesnt work for me...
can some1 explain how to make an average to make readings more precise?
Thanks!

Hello!

I made a temp test in water heating with candle 1 cup of water with a temp meter in water.
I got my readings from 23 to 50 celsius my sensor shows 1c difference with temp meter
But above 50C it goes up like 1.4 1,6 celsius
How can i smooth this values?
i found 1 datasheet 45celsius shows 1k ohm i got 1032ohm i think this 32 ohm is the problem,how can i make it more precise?

My code:

//---------------

byte NTCPin = A0;
#define SERIESRESISTOR 2188
#define NOMINAL_RESISTANCE 2155
#define NOMINAL_TEMPERATURE 25
#define BCOEFFICIENT 3477

void setup()
{
Serial.begin(9600);
}
void loop()
{  
float ADCvalue;
float Resistance;
ADCvalue = analogRead(NTCPin);
Serial.print("Analoge ");
Serial.print(ADCvalue);
Serial.print(" = ");
//convert value to resistance
Resistance = (1023 / ADCvalue) - 1;
Resistance = SERIESRESISTOR / Resistance;
Serial.print(Resistance);
Serial.println(" Ohm");

float steinhart;
steinhart = Resistance / NOMINAL_RESISTANCE; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro)
steinhart += 1.0 / (NOMINAL_TEMPERATURE + 274.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 274.15; // convert to C

Serial.print("Temperature ");
Serial.print(steinhart);
Serial.println(" C");
delay(3000);
}

You are using the simpler Steinhart-Hart formula, with only one coefficient. That won't be as accurate as using the two coefficient formula.

You need to make the reference NTC resistance measurements as accurately as you can, over the entire range that you expect to measure the temperature. You also need to accurately measure the resistance used in the voltage divider with the NTC sensor. Finally, you need to measure the reference temperatures accurately. Consumer grade thermometers are typically accurate to +/- 1 C or worse.

When you are all done, you should not expect accuracy better than about +/- 1 C over the range.

Hello!

And how can i add one more steinhart equations?
And an other thing i hoked this thing up with a 16,2 lcd
It works but i have got a little bug i would like to print temp: 28 °C
but i cant figure it out my lcd now prints temp: 28,51 °C
how can i remove the ,51? so just shows 27 23 31 etc

thanks Ricsi!

I only see Serial.prints in your code.

Serial.print(steinhart, 0); // 0 decimal places

Leo..

blh64:
The most straight forward approach would be to create an array of 1024 elements since that is the resolution of an arduino A2D and then fill it in with the celsius value for the given voltage. With that, you read the analog pin, look up the value in the array and get the corresponding temperature.

You could also model the relationship with some sort of equation and avoid the large array, but that might be more work depending on how linear/non-linear it is and how much accuracy you desire.

Modelling the relationship is probably better than having an array of 1024 int variables on an Uno :wink: OP did not mention the model though.

Thank you guys!
Now i only have 1 little bug this is a temp/pressure sensor
Boost :0,00 Bar
Temp 0 °C
sometimes my boost readings goes 0,000 so an other digit what can cause this?

Nope sometimes randomly my lcd shows 0.000bar but it 0.00 just jumps 1 more digit sometimes...
Im goint to check wiring and connections

No, 0 pressure on sensor just jumps sometimes...
Any one know how can i add one more steinhart formulta to get precise reading from thermistor?

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte NTCPin = A0;
#define SERIESRESISTOR 2188
#define NOMINAL_RESISTANCE 2155
#define NOMINAL_TEMPERATURE 25
#define BCOEFFICIENT 3477
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.clear();
 lcd.setCursor(0, 1);
  // print a message to the lcd.
  lcd.print("Temp:");
  lcd.setCursor(13,1); // Sets the cursor to col 0 and row 0
 lcd.print( char( 223)); lcd.print("C  ");
}
void loop()
{  
int TempsenValue=analogRead(A0);
float ADCvalue;
float Resistance;
ADCvalue = analogRead(NTCPin);

//convert value to resistance
Resistance = (1023 / ADCvalue) - 1;
Resistance = SERIESRESISTOR / Resistance;

float steinhart;
steinhart = Resistance / NOMINAL_RESISTANCE; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro)
steinhart += 1.0 / (NOMINAL_TEMPERATURE + 273); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 273; // convert to C
lcd.setCursor(8, 1);
lcd.print(steinhart,0);
delay(1000);
}

Any one know how can i add one more steinhart formulta to get precise reading from thermistor?

Many people. You just "cut and pasted" the short version.

Can you help me with the long version?