Track My Order
Frequently Asked Questions
International Shipping Info
Mon-Fri, 9am to 12pm and
1pm to 5pm U.S. Mountain Time:
Chat With Us
May 27, 2014
about 4 years ago
To clarify further, the analog pin reading must first be converted to a voltage for this to work.
Supposing you have the middle pin of the TMP36 hooked up to pin A3, you can use this code:
char tempString ;
int tempPin = 3;
int tempRead = analogRead(tempPin);
float tempVolt = float(tempRead) / 310.3;
float tempCelsius = (100 * tempVolt) - 50;
dtostrf(tempCelsius, 8, 2, tempString);
/* dtostrf (from library <stdlib.h>) takes in a float (tempCelsius, in this case) and stores a stringified version of that float in a pre-established character array (in this case, tempString.) This is necessary because if you try to print a float, you get an error. */
Serial.print("Current temperature in Celsius: ");
No public wish lists :(
Forgot your password?
No account? Register one!