hi !

I'm using this code which displays the tension measured on pin A12 and the internal Temperature using InternalTemperature library.
The problem ?

Name:  image_2021-06-18_115759.png
Views: 421
Size:  6.3 KB

As you can see, the first time I display voltage there is no problem, but after getting the temperature, the voltage just displays wrong value.

Anyone already have this problem and/or know how to resolve it ?

Code:
#include <InternalTemperature.h>

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

void loop() {
  Serial.print("\nvoltage = ");
  Serial.println(getVoltage());
  delay(500);
  Serial.print("temperature = ");
  Serial.println(getTemperature());
  delay(500);

}

float getTemperature() {
  return InternalTemperature.readTemperatureC();
}

float getVoltage() {
  return analogRead(A12) * 3.3 * (82 + 10) / float(1023 * 10); //82 & 10 are resistance in kOmh
}
win10/arduino 1.8.13/teensy 3.2