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

Analog Input Readings - LM35 Attached


  • Please log in to reply
11 replies to this topic

#1 muyinteresting

muyinteresting

    Member

  • Members
  • PipPip
  • 19 posts

Posted 04 October 2010 - 05:34 PM

Hi, While I'm not ever so slowly writing my code for my home automation project, I am playing with random things like pulling sensor readings and the like. I have a couple of LM35 temp sensors (http://www.robotshop...e-sensor-1.html) that I bought from RobotShop.ca I wired one up, on analog pin 0 and started reading off values. I am constantly getting very low values under 120. I am getting a consistent series of read offs within 60-110 depending on the temperature. However, for the change in temperature, the range that is appearing is very off. Using the general conversion equation double tempinCel = (5.0 * APin_0 * 100) /1024, I get an annoying read out of 56.XXXXX at room temperature. I am pretty sure that my room is not 56C. As far as I am aware, this sensor provides readouts in Celsius in 10mV per degree. I tested all 3 sensors on all 6 analog IO pins. I get the same readout on all of them of that same sub-100 value. My room is sitting at about 24C, which should produce a value much higher than what I am getting. My ARef is 5V (bridged from 5Vout on the netduino) since I'm powering the sensor with an external power supply. I tried powering from the board itself with 3.3v and 5v. I get the same terrible values, just a bit different because of the reference difference. The netduino firmware is at 4.1.0.3. I wired everything up using every matching schematic I could find for the arduino, etc. It isnt reading out properly. I doubt I got 3 dead sensors in one go? If you can provide any input on this issue, it would be appreciated. Thanks, Muyinteresting

#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 October 2010 - 05:36 PM

Hi Muyinteresting, Netduino's ARM processor supports analog inputs (and AREFs) up to 3.3V. You will need to switch the AREF to 3.3V and use 3.3V with your analog sensor... Chris

#3 muyinteresting

muyinteresting

    Member

  • Members
  • PipPip
  • 19 posts

Posted 04 October 2010 - 05:39 PM

Hi Muyinteresting,

Netduino's ARM processor supports analog inputs (and AREFs) up to 3.3V. You will need to switch the AREF to 3.3V and use 3.3V with your analog sensor...

Chris


I have tried that. I have powered a single sensor from the netduino 3.3v and bridged the ARef to 3.3v, I get the same result as using 5v, albeit with a reduced range.

I confirmed that the ARef is there as my values hold at 1023 without it (as it should). The sensor is being grounded by the netduino.

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 October 2010 - 05:41 PM

I have tried that. I have powered a single sensor from the netduino 3.3v and bridged the ARef to 3.3v, I get the same result as using 5v, albeit with a reduced range.

I confirmed that the ARef is there as my values hold at 1023 without it (as it should). The sensor is being grounded by the netduino.


Have you tried using the AnalogInput.SetRange(...) method to calculate your results instead?

Chris

#5 muyinteresting

muyinteresting

    Member

  • Members
  • PipPip
  • 19 posts

Posted 04 October 2010 - 05:47 PM

Have you tried using the AnalogInput.SetRange(...) method to calculate your results instead?

Chris


I haven't used setrange to calculate my results, however, based on all the readings that I could find, it shouldn't be required. The raw number from IOPin.Read() should be sufficient.

I'll try that when I get home after my classes are done (5pm today! >:\) and experiment with AnalogInput.SetRange().

#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 October 2010 - 06:10 PM

I haven't used setrange to calculate my results, however, based on all the readings that I could find, it shouldn't be required. The raw number from IOPin.Read() should be sufficient.

I'll try that when I get home after my classes are done (5pm today! >:\) and experiment with AnalogInput.SetRange().


Just FYI...if you haven't used Analog.SetRange(...), your default range should be 0-1023.

Chris

#7 muyinteresting

muyinteresting

    Member

  • Members
  • PipPip
  • 19 posts

Posted 04 October 2010 - 06:19 PM

I expected that was the case, which concerns me because my values appear to be far too low.

I'm just running a loop for right now:

AnalogInput AP0 = new AnalogInput(Pins.GPIO_A0);
while (true)
{
Debug.Print(AP0.Read().ToString());
Thread.Sleep(500);
}

With that, I get a constant print out of numbers usually hovering at around 88 (with the aref at 5V) and a little bit lower on 3.3v. I touch the sensor and it takes about 5 seconds to reach a higher value. You can watch the values climb by 1 or a little bit more every pass of the loop.

#8 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 October 2010 - 06:44 PM

With that, I get a constant print out of numbers usually hovering at around 88 (with the aref at 5V) and a little bit lower on 3.3v. I touch the sensor and it takes about 5 seconds to reach a higher value. You can watch the values climb by 1 or a little bit more every pass of the loop.


If you connect analog 0 to GND, do you get a reading of "0"? If you connect analog 0 to 3.3V, do you get a reading of "1023"?

If not, please attach a quick photo so we can see the setup more clearly...

Chris

#9 muyinteresting

muyinteresting

    Member

  • Members
  • PipPip
  • 19 posts

Posted 04 October 2010 - 10:08 PM

Ok.

So, as I expected, I jump A0 to GND and I get a consistent 0 across the board.

ARef is connected to 3.3V on the netduino.

I remove the ARef and keep A0 -> GND and I get random periods of values of 127, 255, and 1023. Just as an aside.

I connect my sensor output to A0. Sensor Vin is also on the 3.3V, GND is to a GND pin on the netduino.

I get the following values, it is around room temperature in my room at the moment:

They don't look right at all. I will do more research though.

71
71
71
70
71
70
71
71
70
70
71
70
70
70
70
71
70
70
70
70
70
69
71
71
70
68
71

I am using the following code to pull my values as a test application:

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace NetduinoApplication1
{
    public class Program
    {
        public static void Main()
        {
            AnalogInput AP0 = new AnalogInput(Pins.GPIO_PIN_A0);
            AP0.SetRange(0, 1023); //Define the default just in case.

            while (true)
            {
                Debug.Print(AP0.Read().ToString());
                Thread.Sleep(250);
            }

        }

    }
}

Pictures are attached of my wiring.
Attached File  IMG00017-20101004-1743.jpg   325.25KB   199 downloads
Attached File  IMG00018-20101004-1743.jpg   375.95KB   212 downloads
Attached File  IMG00019-20101004-1744.jpg   439.27KB   144 downloads

#10 muyinteresting

muyinteresting

    Member

  • Members
  • PipPip
  • 19 posts

Posted 04 October 2010 - 10:19 PM

Ok, after much worry, it appears its working now? WHAT?! I was incredibly frustrated yesterday (hence this whole post), it was spitting out (post formula) readings of 56 and higher when I was running Visual C# on my laptop. Netduino away from any fans. 3.3 * Val * 100 /1024 Now, my issue now is the seemingly super long time it takes for this sensor to report a real reading. It's relatively cool in my room, yet, I touch the sensor, it eventually reaches a higher value, however, it holds that value for a long time. Even after the heat source is long gone. :/ However, there is no issues with the netduino it appears. Emergency averted.

#11 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 04 October 2010 - 10:28 PM

muyinteresting, Glad it's working for you. Interesting note on the transition time for the sensor. Perhaps it's designed for room temperature scenarios (where the temperature changes slowly)? Chris

#12 sterned

sterned

    New Member

  • Members
  • Pip
  • 5 posts

Posted 13 January 2011 - 02:19 AM

Muy, the lowest operating voltage specified by the datasheet is 4 volts. Incidentally, the highest voltage the temp pin should output is 1.7ish volts, so my plan for the LM35 is to run it off the 5 volt pin of the netduino thinking that it *should* not exceed 3.3 volts even though it is on a 5v circuit. I'm also curious to see if the thing works off 3.3V anyway. I've just started testing mine out and haven't gotten it working yet. I'll post back up if I do.




0 user(s) are reading this topic

0 members, 0 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.