0% found this document useful (0 votes)
33 views

TMP36 Sample Code

The document provides sample code to read temperature data from a TMP36 temperature sensor using an Arduino. The code uses analogRead to get a reading from the sensor pin, converts it to voltage, then calculates the temperature in Celsius and Fahrenheit by applying conversion formulas.

Uploaded by

Dc Lamenza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

TMP36 Sample Code

The document provides sample code to read temperature data from a TMP36 temperature sensor using an Arduino. The code uses analogRead to get a reading from the sensor pin, converts it to voltage, then calculates the temperature in Celsius and Fahrenheit by applying conversion formulas.

Uploaded by

Dc Lamenza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Sample Code using TMP36

float temp;
int tempPin = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int reading = analogRead(tempPin);
// converting that reading to voltage,
float voltage = reading * 5.0;
voltage /= 1024.0;
// print out the voltage
Serial.print(voltage);
Serial.print(" volts");

// now print out the temperature


float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((voltage - 500mV) times 100)
Serial.print(“\t”);
Serial.print(temperatureC);
Serial.print(" degrees C");

// now convert to Fahrenheit


float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print( temperatureF);
Serial.println(" degrees F");
delay(1000); //waiting a second
}

You might also like