element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Analog inputs (TMP36) and cable length questions
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 8 replies
  • Answers 2 answers
  • Subscribers 391 subscribers
  • Views 1563 views
  • Users 0 members are here
  • input
  • tmp36
  • arduino
  • analog
  • sensor
Related

Analog inputs (TMP36) and cable length questions

ntewinkel
ntewinkel over 12 years ago

Hi all,

 

I'm trying to do some data logging on my greenhouse, but I'm getting some inconsistent values from my analog pins.

 

Specifically, I have 6 sensors, using all of the UNO's analog pins A0-A5.

I have 2x TMP36 temperature sensors (inside and outside temperature), 2 moisture sensors (nails on wires), a light sensor, and eventually will have a water level indicator for the rain barrel.

 

All the sensors seemed to work well individually when I tested things separately (and with short leads), but now the numbers seem to vary a lot from one reading to the next, at least for my temperature sensors (I think the others need some fine tuning of expected ranges).

 

I take a reading every 15 minutes, and store it in an array. I have a bluetooth adapter hooked up, so I can take my laptop to the room nearest the greenhouse and connect wirelessly to the Arduino that way. I can then type in a command and see the data that was stored, and I can get the current values.

 

To save it from added power drain I thought I would use D12 as my power pin. So D12 is usually low, but just before reading the values I set it high to provide 5V to the two temperature sensors (the other sensors just connect to ground). Come to think of it, I think I'll just keep that set to high to remove that extra unknown image

 

So I'm wondering - do the analog pins need to "settle" at all before I take readings? Right now I set D12 high, wait 1 second, and then read each of the analog pins:

  digitalWrite(power_pin, HIGH);
  delay(1000);
  int insideTemp = readTemp(inside_temperature_sensor);
  int outsideTemp = readTemp(outside_temperature_sensor);
  int moistureLevel1 = readMoistureLevel(moisture_sensor1);
  int moistureLevel2 = readMoistureLevel(moisture_sensor2);
  int waterLevel = readWaterLevel(waterlevel_sensor);
  int sunshineLevel = readSunshine(sunshine_sensor);
  // prints stuff to BTSerial port here
  digitalWrite(power_pin, LOW);

 

The TMP36 sensors are hooked up to 5v, AnalogPin, Gnd (as per the oomlout example).

All of the other sensors are connected just via 2 wires each: ground and analog pin. I'm using the internal pull-up resistors as follows:

  pinMode(moisture_sensor1, INPUT);
  digitalWrite(moisture_sensor1, HIGH);  // use pullup resistor

 

The Arduino is set up in my garage, and uses about 15 feet (5 meters) of CAT-5 cable to connect to the sensors in the greenhouse. CAT-5 has 4 pairs, or 8 wires. I use 1 wire for 5v, 1 for Gnd, and the other 6 are for each of the Analog pins. I soldered a header on the greenhouse end to bring out 6x Gnd connections and 2x 5v connection, so that all sensors can be plugged in that way.

 

So my questions are:

1. Do I need to do anything special for the analog reads, or is my procedure ok? For example, would it make sense to wait between readings, or take 15 readings per pin and use the average?

2. Does the length of the sensor wires cause a problem?

3. Does sharing the GND over that distance cause an issue?

4. I realize that the waterlevel sensor is not connected, but I have a pullup resistor in place which puts it to a constant 5v, or 1023. This wouldn't affect any other pin readings, would it?

 

Thanks!

-Nico

  • Sign in to reply
  • Cancel

Top Replies

  • mcb1
    mcb1 over 12 years ago in reply to ntewinkel +1 verified
    Nico This may give you give the answer. http://forums.adafruit.com/viewtopic.php?f=25&t=11597 I've learned something today so thanks Mark
Parents
  • neilk
    0 neilk over 12 years ago

    Nico

     

    I see Mark has solved this for you, however there are a few other issues which I had when reading from 2 x LM35 (3 wire device, similar to TMP36, I think) temperature sensors:

     

    1. I observed noise with significant amplitude on the Vcc line to the LM35, so I slugged it (at the Arduino end) with 47uF tantalum cap to ground.
    2. More than a few inches of lead resulted in noise on the LM35 signal, so I used twin screened - 1 core for Vcc, 1 core for LM35 output and braid to ground
    3. My maximum signal from the LM35 was less than 3,3V, so I used the 3.3V reference.

     

    I also experienced ADC settling time issues, so, just like you I did dummy reads and with delays, but I also took 10 readings at 100mS intervals and calculated the average.

     

    Eventually, my reading were not only solid, but agreed with an array of digital and mercury in glass thermometers sitting alongside the LM35s

     

    Good luck

     

    Neil

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • ntewinkel
    0 ntewinkel over 12 years ago in reply to neilk

    Thanks Neil!

    It's great to hear from you again image

     

    I'll definitely try those things out.

     

    For the ADC settling bit, I started out as you said, taking multiple readings (I did 8) after the first dummy read, and then returning the average, but after some testing I realized that the result was just as stable with just the one reading, so I thought I would save that second of time image

     

    To start with I did already reduce the problem down to just the simplest circuit with the TMP36 being right at the board, and the temperature is still off by a lot. I noticed that my TMP36 package markings have GZ following it, which seems to mean that they are not quite as accurate (1 degree C typical, 3 degrees max), so maybe I need something more accurate.

     

    My next step (probably after work tonight) is to have all 3 of my TMP36's lined up on a breadboard and then see what kind of results I get from them.

     

    Do you know if these sensors are always off by the same amount? ie, when the docs say it can be off by 1 degree, does that mean that the calibration is off, or does that mean if the temperature is, say, 25 degrees that it will randomly return anything from 24 to 26 degrees depending on random things like moon phases, presence of spiders, etc?

    Did you have to do anything to calibrate your sensors to be so accurate?

     

    ps, Did you ever get your greenhouse setup finished?

     

    pps, I decided to not use Gobetwino because that would mean leaving my laptop on to receive the data. Instead I just use a terminal app to fetch the data when I want to image

     

    Cheers,

    -Nico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ntewinkel
    0 ntewinkel over 12 years ago in reply to ntewinkel

    I noticed I was getting off topic with TMP36 specifics, so I created this new discussion to cover that question: http://www.element14.com/community/thread/24989

     

    Thanks,

    -Nico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 12 years ago in reply to ntewinkel

    I decided the TMP way wasn't, and use the DS18B20 chips for temp sensing.

     

    One thing you can do to create a less noisy supply line is :-

    Feed the supply to these through a diode, and then have a reasonably large 100-1000uF as a filter on the sensor side of the diode.

    You'll be receiving 0.6v less than Vcc, but you can adjust for that when you do the calibration.

     

    I'm also wondering if you slow down the readings ie increase the 10mS time to 100mS,  whether you will gain anything.

    Having a capacitor across the Analogue input is essential, especially since you the input is susceptible to any noise, and the whole circuit is high impedance.

     

    The 47uF across each input (as close as possible to the input) is good, but I would include a 0.1uF to bypass any high frequency noise as well.

    You also need to be careful about where the current flows are, so having a common point where everything originates from/to is the best way to stop current flowing in the ground wires.

    The best way to picture this is two water drains, one small and one large.

    If you make them both finish at the point they enter the ground, then no problems.

    If you make the large one join the small one at any point, some water will flow and affect the small drain.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • mcb1
    0 mcb1 over 12 years ago in reply to ntewinkel

    I decided the TMP way wasn't, and use the DS18B20 chips for temp sensing.

     

    One thing you can do to create a less noisy supply line is :-

    Feed the supply to these through a diode, and then have a reasonably large 100-1000uF as a filter on the sensor side of the diode.

    You'll be receiving 0.6v less than Vcc, but you can adjust for that when you do the calibration.

     

    I'm also wondering if you slow down the readings ie increase the 10mS time to 100mS,  whether you will gain anything.

    Having a capacitor across the Analogue input is essential, especially since you the input is susceptible to any noise, and the whole circuit is high impedance.

     

    The 47uF across each input (as close as possible to the input) is good, but I would include a 0.1uF to bypass any high frequency noise as well.

    You also need to be careful about where the current flows are, so having a common point where everything originates from/to is the best way to stop current flowing in the ground wires.

    The best way to picture this is two water drains, one small and one large.

    If you make them both finish at the point they enter the ground, then no problems.

    If you make the large one join the small one at any point, some water will flow and affect the small drain.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube