I have tried implementing the LMT01 temperature sensor on my Arduino UNO as per the video provided by TI here: https://www.youtube.com/watch?v=CWDX6PdF-ZY. Instead of printing onto an LCD i instead output it through the serial monitor. My code is below:
volatile int pulseCount=0;
float temp = 0;
int hold = 0;
void setup() {
ACSR = B01011010;
ADCSRB = 0;
Serial.begin(19200);
}
// the loop routine runs over and over again forever:
void loop() {
if (pulseCount != hold){
while(pulseCount !=hold){
hold=pulseCount;
delay(1);
}
temp = 0.0625*pulseCount-50;
Serial.println(temp);
pulseCount = 0;
}
delay(2); // delay in between reads for stability
}
ISR(ANALOG_COMP_vect)
{
pulseCount+=1;
}
However I am getting readings which jump between (what I assume is) the correct temperature and the extreme negative of -50 as shown below:
25.12 -50.00 25.12 -50.00 25.06 -50.00 25.06 -50.00 25.06 -50.00 25.06 -50.00
A bit confused here; why is this happening?