Saturday, September 1, 2012

Using Analog Devices TMP36 Temperature Sensor

In order to get some interesting data to display on the LCD panel, a TMP36 temperature sensor was purchased.  A tutorial on AdaFruit was followed for this exercise, and I found it to be quite thorough and well written.

Before connecting the TMP36 to the Arduino, an initial test was performed on the sensor.  It was connected to +5V and GND, and using a multimeter, the Vout pin was read and gave a result in the expected range for my lab which is in desperate need of a little more air conditioning.  Placing a finger on the TMP36, the reading was seen to go up, and putting a soda can against the sensor was also observed to make the reading go down.


The next step was connecting the TMP36 to analog pin 0 on the Arduino.  A quick sketch later, and the LCD panel was reading the rooms ambient temperature.  Unfortunately, the readings (even taken every few seconds) were fairly erratic (values of +/- 8 degrees were observed).  After a bit more reading and investigation, this would seem to be due to noise on the +5V line.


In efforts to get a better reading, the TMP36 was moved from +5V power to +3.3V power, and the AREF pin on the Arduino was used to adjust the analog pin readings.  That calmed the reading jitter down a little (but it was still a bit too unstable for my tastes), and as an unfortunate side-effect, the values started reporting the room temperature to be a bit too high.  Going back to the multimeter, I discovered that my +3.3V line was actually closer to +3.2V.  Adjusting the math in the sketch to account for this voltage difference put the room temperature within expected limits.


Going back to the TMP36 datasheet, the vendor recommended putting a .1uF ceramic capacitor with short leads onto the positive pin of the sensor.  Unfortunately, I did not have one of those laying around, but did have a 100uF 100V capacitor that I plugged in to the circuit (a bit of overkill, but when its all that was available...).  That immediately calmed the readings down to fluctuate between the expected +/- 1 degree.


That is about as far as I plan to take this circuit for the moment.  I have a DHT22 temperature and humidity sensor I'll try out first, before deciding whether its worth my time to go back and write some temperature averaging code to clean up the LCD display.

1 comment:

  1. Wow this such a great article and the tips are very comprehensive. For sure many entrepreneurs with small and big businesses are going to benefit from this. Keep it up!
    Temperature Sensors

    ReplyDelete