The TMP36 temperature sensor operates within a voltage range of 2.7-5.5V, has very low power consumption, and a typical temperature error of ±1℃, with a maximum of ±2℃. For every 1℃ change in temperature, the corresponding voltage changes by approximately 500mV. It requires no external calibration and is suitable for applications in environments ranging from -40℃ to 125℃.
float stl=0;// Floating variable for displaying temperature
void setup()
{
Serial.begin(9600);// Initialize serial port
pinMode(A0, INPUT);// Set analog pin A0 as input for reading data
}
void loop()
{
stl=(analogRead(A0)-20)*0.48816-40;// Read data from pin A0 and calculate temperature; the formula varies based on specific sensor characteristics, this is just an example
Serial.println(stl);// Print temperature
delay(2000);
}
The temperature values returned by the serial monitor can be connected to a host computer for further display or processing.