I am a newbie in the Arduino Community. I am trying to build a room temperature sensor circuit using the TMP-36GZ sensor. However, it keeps giving me the incorrect temperature (~250 deg C).
Show us which pin on the arduino you are using (eg. photo) for the temperature sensor. Need to use one of the analog pins... eg pin 'A0' for analog reading, or pin 'A1' etc.
So pin 'A1' is the physical pin you find on the arduino that really has the label 'A1' on it. When using the 'analogRead' function, I think that analogRead(1) will mean read analog voltage from pin 'A1'.
So make sure you're not using 'digital' pin '1'.
Then..... after you use analogRead, the result is a 10 bit (1024 level) value..... such as 313. Which needs to be converted to a voltage. If the max voltage is 5V, then 313*(5V/1024) = 1.53 V
That voltage 1.53V will be linked to a temperature. But if the sensor doesn't have a table that gives us a temperature value that corresponds to 1.53, then we would need to find out the real temperature linked to this particular voltage value (eg.....borrow an accurate calibrated thermometer from somebody)..... and measure the temperature. This allows us to link 1.53 V to a real temperature.....such as 23.5 degree C (for example). For example, we use somebody's calibrated thermometer to measure a temperature of 23.5 degree. And our own temperature sensor is outputting 1.53 V at this time. This means that 1.53 V can then be associated with 23.5 degree.
This gives us a temperature 'reference' or starting point. And we 'could' (maybe) assume a linear temperature dependence (even if not) for the sensor's output voltage.
So the temperature could maybe be calculated as (for example):
temp = (voltage - voltage_for_known_temp)*known_temp + known_temp
or temp = (voltage - 1.53) * 23.5 + 23.5
So if voltage is 1.53, we'd get temp = 23.5 degrees C
If voltage were 1.6, we'd get temp = 25.15
That's just an example. The actual voltage curve for the sensor (as a function of temperature) might be something different..... so it'll be necessary to check out manufacturer data to get the right picture.