
How do I make the TMP36 temperature sensor more resistant to variances in input voltage? Can I compensate by dynamically reading the aref voltage? How do you read the aref voltage on the internal aref pin on the Netduino?
![]() |
  | |||||||||||||
![]() |
|
![]() |
||||||||||||
![]() TMP36 Temperature Sensor/SB Protoshield
Started by Jason Smith, Aug 10 2010 06:05 PM
37 replies to this topic
#21
Posted 19 February 2011 - 05:55 PM
Okay, I did some more testing. The voltage and corresponding temperature varies according to what power source it's hooked up to. However, the wildly varying readings were due to my front panel USB port provided by my all-in-one card reader. As soon as I hooked it up to the wall or rear USB ports I got much more stable readings (variance within ~1 degree):
![]() How do I make the TMP36 temperature sensor more resistant to variances in input voltage? Can I compensate by dynamically reading the aref voltage? How do you read the aref voltage on the internal aref pin on the Netduino?
#22
Posted 25 February 2011 - 01:10 AM
Hi Jim,
The voltage on the internal AREF should be the same voltage as the 3.3V pin header. You can use the external AREF instead if you want to provide a consistent analog reference between 2.7V and 3.3V DC.
Chris
#23
Posted 15 April 2011 - 02:31 PM
I had similar reading with my scope ... until I grounded it ...
just a thought, I know nothing in electronics, learning as I read about it here and there !
Started with C in 1985, moved to Vb3 ... to vb6 and stopped. Now started with .Net and learning C# and VB.net and wishing VB.net was on MF !
#24
Posted 12 October 2011 - 04:51 PM
Hi Guys!
I'm new in the Netduino community, thanks in advance for your help! I've tried the Jason Smith schema with the Chris Walker recommendations and the tamberg annotation using a LM335 sensor instead of a TP36 one. I attach the resulting schema and the code I'm using to get the Celsius degrees. ![]() private double GetLM335Temp(int ADC_Value) { double voltage = 3.3 - (ADC_Value * 3.3 / 1024); double tempC = (voltage - 0.5) * 100; return tempC; } It seems it works correctly but I have some questions about it: - There are no similar schemas in the LM335 datasheet (http://www.sparkfun....ature/LM135.pdf): what are the differences between both sensors? Should it work? - I have seen a calibrated sensor schema in the datasheet. Do I need a calibrated sensor schema to get the correct temperature values? I'm not sure how to do it, can anybody help me? ![]() Thanks so much!
#25
Posted 12 October 2011 - 06:37 PM
Hello Travis from Venezia, but overall welcome to the forum.
Oh, well...either you posted a wrong picture about how to connect the probe, or I'd suggest you to detach immediately! Your bottom picture is the correct one, but the Fritzing wiring picture is not the same, and you may even burning the probe. Here is the original datasheet. The differences among the 135/235/335 are only about the temperature range capability (top-right of page 2). The ideal circuit would be a constant-current source instead of R1. Anyway, let's keep it easy. Instead, R1 should be chosen accordingly to the available V+, that is the supply of the probe. Since the probe is designed to drop 2.98V @ 1mA @ 25'C (page 2), I suggest to use the +5V supply instead of the +3.3V, because it is too close to the working point. Thus, the Ohm's law tell us that: R1 = (5 - 2.98) / 1 mA = 2020 Ohms Of course it's a strange value, but you may obtain by placing in series two very common values as 1.8K and 220 Ohms. The 10K trimpot is also required for a better calibration. Last thing... The specs (page 1) state that the probe increases its voltage drop of 10mV for each Kelvin (i.e. Celsius). Since the max absolute voltage that can be applied on any analog input of the Netduino is +3.3V, you can't measure temperatures above: Tmax = 25'C + (3.3 - 2.98) / 10mV = 57'C If that is an issue, you must add some extra hardware to "squeeze" the voltage within the reliable bounds. Hope it helps. Cheers
Biggest fault of Netduino? It runs by electricity.
#26
Posted 13 October 2011 - 01:41 PM
Thanks so much for your time, Mario!
I don't have the necessary resistors now, I'll tell you when I can try it.
Bye!
#27
Posted 13 October 2011 - 07:30 PM
Hi everyone!
I've tried it again Mario and this is the resulting schema. ![]() And the code I'm using to get the Celsius degrees. double voltage = ADC_Value * 5.0 / 1023; double tempK = voltage * 100; double tempC = tempK - 273.15; I think I have done it correctly this time, but I get values between 180 and 190. Is there something wrong? Do I need to do a calibrated sensor? Thanks for your help!
#28
Posted 14 October 2011 - 03:55 AM
Travis...almost right, but not yet!
First off, you should add the 10K trimpot. Maybe you don't need any adjustment, but you could not leave the third lead free.
Secondly, it's correct that the probe is +5V powered, but the ADC range is -and always be- +3.3V. So, your "voltage" variable must be multiplied by 3.3, not 5.
After that you should have your probe working properly.
Note that if you have a Netduino Plus you *MAY* have a little jittering on the ADC values, only when the Ethernet connector is plugged in.
Just in case, test the probe without the connector, then add an average algorithm to minimize the noise effects.
Cheers
Biggest fault of Netduino? It runs by electricity.
#29
Posted 15 October 2011 - 11:35 AM
Is the same component a potentiometer than a trimpot?
I used a potentiometer and this is the resulting schema: ![]() I calibrated the potentiometer for reading 2.982 V at 25 degrees, is that correct? It seems to work properly! When the Ethernet connector is plugged in, I get values with differences up to 10 degrees. Without the connector the difference is less than 2 degrees. Can I avoid the jittering? If not, I will program an average algorithm. Thanks so much Mario!
#30
Posted 15 October 2011 - 12:38 PM
I have found that adding 100uF across the +5V and +3.3 volt power supplies helps remove much of the jitter on the ADC conversions. I also use averaging software like this: <snip> // take three readings, spaced a bit in time // insist that all three results are 'close' // then take the average ds2 = ADC1.Read(); Thread.Sleep(delay); ds3 = ADC1.Read(); limit = 20; // max number of loops do { Thread.Sleep(delay); ds1 = ds2; ds2 = ds3; ds3 = ADC1.Read(); } while (!near(ds1, ds2, ds3) && (--limit > 0)); int value = average(ds1, ds2, ds3); <snip> public static Boolean near(int x, int y, int z) // compare three samples { if (abs(x - y) > 1) return false; if (abs(x - z) > 1) return false; if (abs(y - z) > 1) return false; return true; } public static int abs(int x) { if (x >= 0) return x; return -x; } public static int average(int x, int y, int z) { return (int)(System.Math.Round(x + y + z) / 3.0); } If you have only one input to the ADC, your value may settle down faster than mine does. Since there is only a single ADC conversion register, switching between analog inputs means waiting longer for the process to arrive at a "good" digital value.
#31
Posted 15 October 2011 - 01:00 PM
There is an interesting thing to know about the ripple on the ADC.
I own a "Revision A" board, and I've noticed that on "Revision B" there is a good filter on the Aref signal.
You both guys, what revision is marked on your board?
(The mark is printed close to the analog inputs).
Cheers
Biggest fault of Netduino? It runs by electricity.
#32
Posted 15 October 2011 - 01:44 PM
I might be mistaken, but I think on rev a boards there is no internal connection between aref and 3.3v? And his wiring is without a connection to aref, so it should be rev b.
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"
#33
Posted 15 October 2011 - 01:52 PM The main difference between Rev A and Rev B is just the Aref short, which is missing on Rev A (the mine). Well, you are probably right, since he didn't draw the Aref wiring on his Fritzing picture. If so, it means that neither the Aref filtering (double cap + inductor) solved the jittering problem. However, I'm setting up a small circuit...maybe I'll try something. Cheers
Biggest fault of Netduino? It runs by electricity.
#34
Posted 15 October 2011 - 03:44 PM
Hi!
I've a Rev B Board.
#35
Posted 15 October 2011 - 04:09 PM
Hi Mario, My boards are Rev B. Thanks, Robert
#36
Posted 03 November 2011 - 09:28 PM
I'm using port A1, why am I getting 198 as a value when it really is about 24 celcius? I'm using LM335Z
double voltage = tempA1.Read() * 3.3 / 1024;
double tempC = (voltage - 0.5) * 100;
Anyone could help please?
Cheers!
Coco
#37
Posted 04 November 2011 - 05:03 AM Why are you using this formula? Assuming that 198 is the value on "tempC", it seems that the probe is working correctly. First off, avoid using "double", which is much more heavy to manage, and you don't need an high precision. The float (Single) is surely better in this context, and *probably* the CPU is able to manage them natively. float voltage = tempA1.Read() * 3.3f / 1024; //note the "f" suffixAfterward, the probe should give a voltage of 2980mV (i.e. 2.98V) at 25'C, thus: float tempK = voltage / 10; //temperature in Kelvin float tempC = tempK - 273; //temperature in CelsiusCheers
Biggest fault of Netduino? It runs by electricity.
#38
Posted 21 February 2014 - 03:13 PM
Hi Chriss,
could you like to paint the wiring 3V3 with AERF... for me to better understand. Secondly my netduino has no AREF..there is IOREF port..is it the same ?
thanks for answer 1 user(s) are reading this topic0 members, 1 guests, 0 anonymous users | ||||||||||||||
![]() |
||||||||||||||
![]() |
|
![]() |
||||||||||||
![]() |
This webpage is licensed under a Creative Commons Attribution-ShareAlike License. | ![]() |
||||||||||||
![]() |