Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Total Newbie Temperature Project


  • Please log in to reply
33 replies to this topic

#1 cobolstinks

cobolstinks

    Member

  • Members
  • PipPip
  • 27 posts

Posted 22 November 2011 - 03:25 PM

I know very little about electronics, but I'm a developer and have worked in C#, java, and unfortunately cobol. I'm also into homebrewing beer. So I'd like to take on a little project that would have 3 maybe 4 temperature senors which i would place in my kettles, and display their temperatures on a display. I would like to monitor temperatures from 0C - 100C, but the sparkfun breakout boards ive been looking at (http://www.sparkfun.com/products/9418) say they only go up to 85c. Does anyone have any recommendation on parts for this? Sorry that I'm a total newbie at this stuff, I have no doubts i can handle the programming side of things, I'm just not used to working in the physical realm :)

#2 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 23 November 2011 - 01:30 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

#3 cobolstinks

cobolstinks

    Member

  • Members
  • PipPip
  • 27 posts

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 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 23 November 2011 - 06:38 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
Biggest fault of Netduino? It runs by electricity.

#5 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

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 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

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 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 23 November 2011 - 08:26 PM

I just did a quick search on ebay to check for prices; they have quite a few LM35 devices for sale from UK sellers. The cheapest devices are the LM35DZ, the D means the range is 0 to 100 degrees, and the Z means that it comes in a TO-92 plastic transistor style package. This is the style I used previously, quite small and easily glued into a glass rod. They are about £1 each plus postage. As ever with ebay you pay your money and take your chances!

#8 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 24 November 2011 - 05:14 AM

Perfect!
Biggest fault of Netduino? It runs by electricity.

#9 cobolstinks

cobolstinks

    Member

  • Members
  • PipPip
  • 27 posts

Posted 25 November 2011 - 09:20 PM

ordered 4 lm35's got my VS setup and a basic netdunio project started. Ill have to do some reading up on breadboards and basic electronics. Thanks for the advice.

#10 Coding Smackdown

Coding Smackdown

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationLewisville, TX USA

Posted 25 November 2011 - 10:18 PM

Are you planning on doing temperature monitoring or temperature control?
Brewing Award Winning Beer with a Netduino!
http://diybrewery.com

#11 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 26 November 2011 - 08:21 AM

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.

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.

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 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 26 November 2011 - 10:13 PM

Hi Mark, Even better, set the reference to 1.023 V. That way its all integer arithmetic. How do you tell the Netduino to use ARef instead of 3.3V? (I know there is an analogue switch on the Netduino PCB.) What is the C# command to throw the switch? Paul

#13 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 27 November 2011 - 08:35 AM

How do you tell the Netduino to use ARef instead of 3.3V?


See this thread.

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


#14 cobolstinks

cobolstinks

    Member

  • Members
  • PipPip
  • 27 posts

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 cobolstinks

cobolstinks

    Member

  • Members
  • PipPip
  • 27 posts

Posted 29 November 2011 - 12:46 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!

#16 Coding Smackdown

Coding Smackdown

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationLewisville, TX USA

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
Brewing Award Winning Beer with a Netduino!
http://diybrewery.com

#17 cobolstinks

cobolstinks

    Member

  • Members
  • PipPip
  • 27 posts

Posted 02 December 2011 - 04:29 AM

ok got everything, did the led tutorial on pressing onboardsw1 to toggle the onboard LED, no problemo with that.

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:16
Some of the values might be correct. Im in my basement and its probably around 20C
Posted Image
Posted Image
Posted Image
Posted Image
Posted Image
Posted Image
Posted Image
Posted Image
Posted Image

#18 Coding Smackdown

Coding Smackdown

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationLewisville, TX USA

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!
Brewing Award Winning Beer with a Netduino!
http://diybrewery.com

#19 Arron Chapman

Arron Chapman

    Advanced Member

  • Members
  • PipPipPip
  • 289 posts
  • LocationOregon, USA

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 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 02 December 2011 - 07:58 AM

I made a mistake in this post. Which I did not spot until I was at work. I am re-writing it now..... Paul

Edited by Stefan, 02 December 2011 - 04:58 PM.
removed attachments by request of Paul himself





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.