Created
September 16, 2022 07:48
-
-
Save jenschr/c0d2d5df453742a9af9ee97484cc0877 to your computer and use it in GitHub Desktop.
tmp36.ino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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