Go Down

Topic: Having temperature spikes with TMP36 (Read 2902 times) previous topic - next topic

robtillaart

Quote
I much prefer the form:
Code:
Temp += 0.05 * (Reading-Temp) ;

You don't have to remember to change both constants each time and its provable stable when Reading == Temp even with floating point rounding issues.  both 0.95 and 0.05 are inaccurately represented in floating point and in particular 0.95+0.05 may not equal 1.0

- and it performs faster too (replacing 1 floating multiply by 1 floating subtraction)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Docedison

The TMP36 is an accurate and easy to use with an ADC and oversampling is certainly the way to measure temperature.
(I would take 50 or so readings every hundred milliseconds and average) but what I don't understand here is why it is
necessary to use any temp data that came during the command to the 'relay' or for that matter any other command
sequence or event, unless the device is in a PID loop. Although the long thermal inertia of the '36 would eliminate even
that concern... IMHO

Doc
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

plisskin

I did a similar project recently, and had similar issues using a TMP36.  I only had a single relay and an LCD shield.  Everytime I would energize the relay or turn on the backlight on the LCD shield, my temperature would jump up be several degrees (°C).

I tried taking several raw values and averaging them before converting to a temperature and it helped but still had issues.  I noticed that the reference voltage would drop ever so slightly as I turned on the outputs and determined this is what was making the temperature jump.  Then I tried using a precision voltage reference (REF5040) but still saw some jumps in temperature.  My final solution was to replace the TMP36 with a DS18B20 and all of my issues went away.  I did not even have to modify my wiring too much as I switched the analog input I was using to be a digital input and carried on.

This was my first arduino project and I used a clone that I bought off of eBay.  I'm not sure if this clone is inferior quality and maybe the TMP36 would work better with a real arduino or not but I was unable to successfully use a TMP36 in a way that would work for me.

Chris

robtillaart

Quote
I only had a single relay and an LCD shield

Did you have a separate powersupply for the relay? that is often advised to prevent power drops.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

plisskin

For the relay, I used the 5v from the Arduino Uno board which I assumed is not being sourced by the Ardiuno itself, but the voltage regulator and just drove a transistor using the Arduino output.  I will admit that I never looked at the schematic to verify the 5v source though.  The relay module I used was also from eBay.

Since the Arduino analog inputs are only 10-bit, a raw value change of two jumps almost an entire degree (°C).  Filtering helped this obviously but I still saw the temperature going up when the power dropped and because a small raw change caused such a large temperature increase, I ended up moving to a digital device.

robtillaart

Quote
Since the Arduino analog inputs are only 10-bit, a raw value change of two jumps almost an entire degree (°C).

If you know that the temperature stays within a certain range, you can use a voltage divider on th AREF pin to increase the sensitivity of the analogRead().

e.g. if for 5V the range of the tmp36 stays between 300 (~1.6V) and 600(~3.2V), one could supply 3.3V to AREF

the measurements range would become ~450 - 900 effectively increasing the # bits per degree.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up