Total Newbie Temperature Project
#1
Posted 22 November 2011 - 03:25 PM
#2
Posted 23 November 2011 - 01:30 PM
#3
Posted 23 November 2011 - 02:33 PM
Twenty years ago I was using LM35 sensors to measure the temperature in a beaker of liquid for a school project.
I have just checked and they are still available for about £3.50 each.
The LM35 is very simple to use.
It looks like a plastic transistor with three legs, one leg is ground, one leg is positive supply (4V-20V) the other leg gives a voltage proportional to temperature.
Unlike thermistors, the voltage is linear - 10mV per degree Celsius.
e.g.
0.5V = 50 degrees C,
1.0V = 100 degrees C.
(If you want to measure temperatures below 2 degrees C (down to -55 !), you also need to use a negative voltage and a resistor. But note that the voltage will go negative when the temperature is below zero and the netduino can't measure it directly!)
For the school project, I put the 3 sensor wires into a glass rod and used two part adhesive to stick the sensor to the end of the rod and thus seal the wires from the liquid.
There is a data sheet here, (it is very simple to understand, just look at the pictures on page 1 and 2):
http://www.national.com/ds/LM/LM35.pdf
So in short, you should be able to connect (solder) three wires to the sensor, and connect one wire to the netduino's 5V, one to the ground, and one wire to one of the six analogue inputs. No other components are needed.
In the netduino software, you will need to sample the chosen analogue input, and scale the number read so that it is in volts and multiply by 100 for degrees C.
Hope this helps
Paul
Thanks for the response Paul, I think i can handle that wiring. To convert the analog input to C, would this be correct (a0 * 5)*100 where a0 is the input from analog port 0 (assuming i hook up the sensor to that port).
Just ordered my neduino plus, super excited to get started.
#4
Posted 23 November 2011 - 06:38 PM
#5
Posted 23 November 2011 - 07:06 PM
Hmmm...just to be clear.
You cannot wire a sensor that outputs a voltage above +3.3V to the Netduino. This is allowed on the Arduino (powered at +5V), but the Netduino is working at +3.3V.
That means that the sensor must be connected using a voltage divider. For simplicity, two 10K resistors will half the actual sensor voltage.
This forum has plenty of examples/posts about the analog conversion of temperature sensors.
Cheers
Whilst you are quite right to warn that the Netduino can only handle a maximum of 3.3Volts on its inputs, in this case (using the LM35) I believe there is no danger unless the user makes a mistake with the wiring or perhaps the device blows up.
There actually seem to be three variants of the LM35 in the data sheet,
- the LM35D is rated to measure temperatures between 0 and +100 degrees C.
- the LM35C and LM35CA are rated to measure temperatures between -40 and +110 degrees C.
- the LM35 and LM35A are rated to measure temperatures between -55 and +150 degrees C.
Hence in normal use the maximum voltage presented to the Netduino would be 1.5 Volts at 150 degrees C.
As I mentioned before to measure below 2 degrees (not possible on the LM35D), a negative voltage would be needed to bias the device using extra components (see figure 2 on page 1 of data sheet). This negative voltage would NOT be compatible with the Netduino.
In normal use I think the main risk would be a short circuit between the 5V supply and the analogue input. So keep the soldering neat and use a sleeve over at least the centre pin to isolate it from the other two.
Paul
#6
Posted 23 November 2011 - 07:34 PM
Thanks for the response Paul, I think i can handle that wiring. To convert the analog input to C, would this be correct (a0 * 5)*100 where a0 is the input from analog port 0 (assuming i hook up the sensor to that port).
Just ordered my neduino plus, super excited to get started.
I am still quite new at this too so someone correct me if I am wrong!
The Netduino ADCs are 10-bits, e.g. 0 to 1023.
My understanding is that a voltage of 3.3V will give the maximum reading of (1023) 0x3FF.
For this sensor, we need to convert the number read from the port to Volts and then multiply by 100.
To convert to Volts, we divide by the maximum reading 1023, and then multiply by the maximum voltage 3.3.
Then we multiply by 100 for degrees C.
Putting it all together: multiply by 330 then divide by 1023.
Ideally you would do the calculation using a floating point variable, but if you want to work with integer arithmetic, always do the multiply first then the divide. That way you minimise the loss in precision.
A worked example:
If the LM35 is measuring 55 degrees C the output voltage will be 0.55 Volts.
The ADC reading will be 170 or 171.
Lets say its 170; then ((170 * 330) / 1023) = (56100 / 1023) = 54.83 (integer arithmetic would give 54)
(If the ADC had read 171, this would give 55.16)
Just for fun - if you were working in integer arithmetic and you applied the divide first by mistake:
((170 / 1023) * 330) = (0 * 330) = 0 !!
Paul
#7
Posted 23 November 2011 - 08:26 PM
#8
Posted 24 November 2011 - 05:14 AM
#9
Posted 25 November 2011 - 09:20 PM
#10
Posted 25 November 2011 - 10:18 PM
http://diybrewery.com
#11
Posted 26 November 2011 - 08:21 AM
Whilst 3.3V is the maximum voltage the A/D converters can handle you could feed them a lower reference voltage. Set ARef to 1V and then 1023 = 1V.My understanding is that a voltage of 3.3V will give the maximum reading of (1023) 0x3FF.
For this sensor, we need to convert the number read from the port to Volts and then multiply by 100.
Regards,
Mark
To be or not to be = 0xFF
Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life
Follow @nevynuk on Twitter
#12
Posted 26 November 2011 - 10:13 PM
#13
Posted 27 November 2011 - 08:35 AM
To be or not to be = 0xFF
Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life
Follow @nevynuk on Twitter
#14
Posted 29 November 2011 - 12:39 AM
Are you planning on doing temperature monitoring or temperature control?
Just want to monitor 4 sensors. 1 in my brew kettle, 1 in Mash Tun, 1 in Hot Liquor tank, 1 in post wort chiller. Than maybe have it do things like tweet or SMS if the temps are outside of an acceptable range.
#15
Posted 29 November 2011 - 12:46 AM
#16
Posted 29 November 2011 - 04:40 AM
got my netduino today, but can't look at it until Thursday (homework and a major release at work). Im sorry im such a newbie, but from the tutorials Ive looked at I was going to feed my sensors from the 3.3v output on the netdiuno, is this not what i should be using to power it?
Also if i were to power LED's from the netduino, which size resistor do i need to step down the 3.3v port? 1/2 watt 68Ohm? Anyone know of a good tutorial link for doing basic things with LEDs?
Thanks!
I've got several TMP36 sensors running off of the 3.3V supply. I think if you were going to say multiplex a lot of sensors then you might want to look into a different power source, but you should be OK.
If you want a good tutorial that covers LEDs check out the Netduino for Beginners post in the General Discussion area, its really good.
I'm finishing up a temperature monitoring project for my walk-in fermenter that has a web based interface. Once I have it all complete I'll post it to the forum to give you some ideas.
Cheers
http://diybrewery.com
#17
Posted 02 December 2011 - 04:29 AM
I wired up a LM35 sensor based off the work here:
http://forums.netdui...-lm35-attached/
My temp readings are all over the place. Can someone please double check my setup?
CODE:
using System; using System.Net; using System.Net.Sockets; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; namespace brewduino { public class Program { public static void Main() { AnalogInput aI0 = new AnalogInput(Pins.GPIO_PIN_A0); aI0.SetRange(0, 1023); while (true) { Debug.Print("RAW:"+aI0.Read().ToString()); Debug.Print("TempC:"+(aI0.Read()*330)/1023); Thread.Sleep(400); } } } }
Output
RAW:17 TempC:6 RAW:58 TempC:10 RAW:21 TempC:0 RAW:44 TempC:5 RAW:44 TempC:19 RAW:60 TempC:22 RAW:9 TempC:11 RAW:56 TempC:8 RAW:0 TempC:0 RAW:0 TempC:0 RAW:0 TempC:0 RAW:1 TempC:4 RAW:27 TempC:16Some of the values might be correct. Im in my basement and its probably around 20C
#18
Posted 02 December 2011 - 05:18 AM
My temp readings are all over the place. Can someone please double check my setup?
I experienced the same thing. You are probably experiencing some noise from the Ethernet interface.
There is another thread in the forum that discusses the issue in some depth.
http://forums.netdui...ading-accuracy/
It is best to hook a .1uF capacitor between 3.3V and Ground to help drop some of the noise. If that doesn't work add a 1mH inductor between the ARef port and 3.3V.
I still had a lot of noise from the senors so I ended up performing 100 reads of the port and then averaging the reading:
int totalReads = 0;
for(int x = 1; x < 100; x++)
{
totalReads += Port.Read();
Thread.Sleep(10);
}
float reading = totalReads / 100;
This seems to work pretty good and is pretty fast for normal monitoring. It may not be the best performance wise, but you can vary the number of reads until you get a good smooth value back.
BTW: Are the two outer leads of your sensor actually hooked to anything? Your circuit looks strange since the two side rails on my breadboard do not have any connection to the inner holes. Try moving the pins over to the first set of holes that your leads are connected to and see if that makes a difference. Take a look at the breadboard diagram I did of my circuit here http://forums.netdui...erature-logger/ the TMP36 is pretty much pin compatible with the LM35.
Cheers!
http://diybrewery.com
#19
Posted 02 December 2011 - 07:46 AM
BTW: Are the two outer leads of your senor actually hooked to anything? Your circuit looks strange since the two side rails on my breadboard do not have any connection to the inner holes. Try moving the pins over to the first set of holes that your leads are connected to and see if that makes a difference. Take a look at the breadboard diagram I did of my circuit here http://forums.netdui...erature-logger/ the TMP36 is pretty much pin compatible with the LM35.
You may be onto something here, I don't see any connections to either GND or V+ which means the pin is basically floating, which will result in inconsistent readings
When you talk EE use small words, I'm just a Software Developer
My Blog/Site and Everything Else
If my post helped you please consider pressing the "Like This" button in the bottom right-hand corner.
Oh my. So many things, so little money!!
#20
Posted 02 December 2011 - 07:58 AM
Edited by Stefan, 02 December 2011 - 04:58 PM.
removed attachments by request of Paul himself
- Arron Chapman likes this
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users