Hi,
I'm using the below code on an Arduino uno and I am getting the correct temp of 20 degrees celsius. The exact same code on an Arduino Uno R4 Wifi is giving me a temp of 27 degrees.
I have put the LM35 direct to 5v pin.
I was using this on the Uno but noticed this doesnt work on the Rev4 Wifi analogReference(INTERNAL);
What am I doing wrong?
#include <SPI.h>
#include <SimpleTimer.h>
//pins:
// Define the analogue pin used to read the temperature sensor (A1) */
const int LM35Pin = A1;
SimpleTimer timer;
int Temperature;
float temp_val;
/////////////////////////
void setup()
{
Serial.begin(9600);
timer.setTimeout(3600000L, [] () {} ); // dummy/sacrificial Function timers with ID 0 cannot be turned on/off
timer.setInterval(1000, CheckTemp); // Miliseconds to seconds, every second run function
}
void loop()
{
timer.run();
}
void CheckTemp()
{
Temperature = analogRead(LM35Pin); /* Read Temperature */
temp_val = (Temperature * 4.88); /* Convert adc value to equivalent voltage */
temp_val = (temp_val / 10); /* LM35 gives output of 10mv/°C */
Serial.println(temp_val);
}