Member Since: May 27, 2014

Country: United States

  • 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:

    #include <stdlib.h>
    char tempString[10] ;
    int tempPin = 3;
    void setup(){
    void loop(){
        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 :(