Not getting the accurate reading with this code. void loop() {
Vo = analogRead(A0);
Serial.print("ADC value :");
Serial.print(Vo);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
Serial.print("Thermistor resistance: ");
Serial.println(R2 );
tKelvin = (Beta * roomTemp) / (Beta + (roomTemp * log(R2 / Ro)));
tCelsius = tKelvin - 273.15;
tFahrenheit = (tCelsius * 9.0) / 5.0 + 32.0;
Can you show the readings you are getting, versus the readings you expect?
How do you read R1 and R2?
What will become of tCelsius, tFahrenheit, tKelvin, roomTemp, and Beta?
// must identify and "type" the variables
float Vo;
float Ro;
float R1;
float R2;
float tCelsius;
float tFahrenheit;
float tKelvin;
float roomTemp;
float Beta;
void setup() {
Serial.begin(115200); // must start Serial communications at a (datarate)
}
void loop() {
// Vo = analogRead(A0);
Vo = map(analogRead(A0), 953, 115, 0, 100); // map NTC (953 low, 115 high) to positive numbers
R2 = R1 * (1023.0 / Vo - 1.0);
Serial.print("ADC value: ");
Serial.print(Vo - 19.0); // adjust reading to range from -24.0 to +80.0
Serial.print(" Thermistor resistance: ");
Serial.println(R2);
tKelvin = (Beta * roomTemp) / (Beta + (roomTemp * log(R2 / Ro)));
tCelsius = tKelvin - 273.15;
tFahrenheit = (tCelsius * 9.0) / 5.0 + 32.0;
delay(2000);
}
1 Like
How do you have it connected? We need to know the way you are measuring the resistance, it makes a difference! Also the component values and A LINK to the exact thermistor you are using; eg
https://www.jameco.com/z/NTC-103-R-Jameco-ValuePro-Thermistor-NTC-K-10-10k-Ohm_207037.html
1 Like
Hi,
Can you please post a circuit diagram so we can see how your NTC is connected?
What model Arduino are you using?
Thanks.. Tom..
![]()
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.