Skip to content

Instantly share code, notes, and snippets.

@kevinl95
Created May 5, 2018 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinl95/5b316d09670088a521846b4050380b99 to your computer and use it in GitHub Desktop.
Save kevinl95/5b316d09670088a521846b4050380b99 to your computer and use it in GitHub Desktop.
void setup()
{
Serial.begin(9600); //Start the serial connection with the computer
//to view the result open the serial monitor
}
void loop()
{
int reading = analogRead(9);
// Teensy reference voltage is 3.3V
float voltage = reading * 3.3;
voltage /= 1024.0;
// 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(temperatureC);
// Print a space
Serial.print(' ');
// now convert to Fahrenheit
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF);
// New line
Serial.print('\n');
delay(60000); //waiting a minute
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment