Skip to content

Instantly share code, notes, and snippets.

@jenschr
Created September 16, 2022 07:48
Show Gist options
  • Save jenschr/c0d2d5df453742a9af9ee97484cc0877 to your computer and use it in GitHub Desktop.
Save jenschr/c0d2d5df453742a9af9ee97484cc0877 to your computer and use it in GitHub Desktop.
tmp36.ino
int sensorPin = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int reading = analogRead(sensorPin);
// measure the 5v with a meter for an accurate value
//In particular if your Arduino is USB powered
float voltage = reading * 4.68;
voltage /= 1024.0;
// now print out the temperature
float temperatureC = (voltage - 0.5) * 100;
Serial.print(temperatureC);
Serial.println(" degrees C");
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment