Read Thermistor Temp. Data from Teensy?

I'm attempting to read temperature data from a simple 2-pin thermistor sensor. I'm using a Teensy 4.0.

I've used this simple thermistor many times, and it has worked very well so far with both Teensys and Arduinos. However, I'm running into an issue with this set of thermistors lately, only on the Teensy.

I first connected the thermistor to my Arduino Uno R3, according to the following Arduino tutorial.

The thermistor I'm using has a resistance value of 10K, and so has the resistor I'm using in my circuit, instead of the 100K they use in the tutorial I used, as such:

Click image for larger version. Name:  image0.jpg Views:  0 Size:  285.2 KB ID:  31168

Alongside the following code, as per the same Arduino tutorial above:

Code:

int ThermistorPin = A0;
int Vo;
float R1 = 10000;
float logR2, R2, T;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;

void setup() {
Serial.begin(9600);
}

void loop() {

  Vo = analogRead(ThermistorPin);
  R2 = R1 * (1023.0 / (float)Vo - 1.0);
  logR2 = log(R2);
  T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  T = T - 273.15;
  T = (T * 9.0)/ 5.0 + 32.0; 

  Serial.print("Temperature: "); 
  Serial.print(T);
  Serial.println(" F"); 

  delay(500);
}

The setup and code above work to produce correct temperature readings from the sensor.

I then went to build the same setup with my Teensy 4.0, as such:

Click image for larger version. Name:  image1.jpg Views:  0 Size:  280.3 KB ID:  31169

Using the same exact code.

However, this setup does not work correctly, and my temperature values are off. I also tried swapping out the 10K resistor for a 100K one, to no avail.

What is going wrong here with the Teensy? As far as I understand, the Teensy data pins are each rated for 3.3V, which should not be an issue here.

Thanks for reading my post, any guidance is appreciated.

Doesn't the Teensy have a 12-bit A/D (with 3.3volt logic).

R2 = R1 * (1024.0 / (float)Vo - 1.0);
R2 = R1 * (4096.0 / (float)Vo - 1.0);
T = (T * 9.0)/ 5.0 + 32.0;
T = (T * 9.0)/ 3.3 + 32.0;

Leo..

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.