Read Thermistor Temp. Data from Teensy?

Svarun123

Member
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:

image0.jpg

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:

image1.jpg

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.
 
You are powering the thermistor-resistor divider from the 5V. You better power it from the 3V3 pin ["3V"]:
[1] the Teensy will not survive a voltage higher than 3V3 on its input pins,
[2] the ADC range of the Teensy is 0V - 3V3.

Paul
 
You are powering the thermistor-resistor divider from the 5V. You better power it from the 3V3 pin ["3V"]:
I know that with the potential divider that you should only see circa 2.5V on A0 but if one or other of the pins become
unconnected it is possible that A0 might have seen 5V and have been damaged.

I use this library for reading thermistors without problem.

It can be used without parameters where values will be assumed for parameters or with user supplied parameters, see below:
Code:
Thermistor(
	uint8_t pin,
	bool genericSimpleFormula = true,
	long seriesResistor = SERIESRESISTOR,
	long thermistorNominalResistance = THERMISTORNOMINAL,
	float temperatureNominal = TEMPERATURENOMINAL,
	long bCoefficent = BCOEFFICIENT,
	uint8_t numSamples = NUMSAMPLES);
I suggest, use 3V3 for Thermistor supply, try another input pin and try the above library.
 
Back
Top