2

I have a quick question to ask. I have an Arduino Uno reading 4 temperature sensors (LM35) in 4 different rooms. What happens is that the two nearest rooms give stable values, while the two further ones give very unstable measurements (the temperature keeps floating +-30C around the real values.)

I have connected all the sensors with Ethernet cables with the longest one being about 8-10m.

Is this problem due to noise picked up along the line? There are no strong electromagnetic sources along the way. I have also measured the voltage values on Arduino end with a multimeter: the values are all stable (and correct) and do not reflect the behaviour detected by Arduino.

Also, I have tried to substitute the LM35 in the farthest room with a photoresistor (the one in the starter kit) and this time the values read by Arduino are perfectly stable. I know that the LM35 works because I have tested it on a breadboard.

Can someone give my some help? Any idea is greatly appreciated.

Edit: I am adding a sketch, although it is a very basic setup: The only difference with the real layout is that there is also a Ethernet shield.

circuit schematics

6
  • Can you show a schematic, preferrably with the ethernet wiring explicitly labelled. You might benefit from adding a line driver circuit to either end, or switch to a digital temperature sensor such as a DS18S20. Alternatively you could get some wonderfully cheap NRF24 modules and have everything wireless; that's worked for me. Commented Sep 2, 2016 at 21:59
  • Thanks, the NRF24 is really nice, but I am afraid that I do not have enough space for its library on Arduino. But if I switch to a digital temp sensor wouldn't I face the same problem and need a line driver anyway?
    – gabelach
    Commented Sep 3, 2016 at 8:57
  • 1
    I don't know; it depends on how you wire it. When I said "Ethernet wiring explicitly labeled" I meant for you to show the colours of the conductors you used. Not Fritzing's make-believe version: what YOU are actually using. Commented Sep 3, 2016 at 9:07
  • 30C is quite a variation... you're looking at ±300mV variance in your analog signals. Check for loose connections in your wiring. Also check what voltage the LM35 receives on its power pin after the long run of Ethernet cable.
    – Majenko
    Commented Sep 3, 2016 at 9:52
  • Sorry, I misunderstood your post. I am using the green, orange and white-orange conductors for 5V, ground and signal, respectively. The voltage received by the LM35 is around 4.2V and with a multimeter I do not see that kind of variance. The problem also remains if I change the analog inputs on Arduino.
    – gabelach
    Commented Sep 3, 2016 at 12:21

2 Answers 2

1

The LM35 has trouble driving any kind of capacitive load, so the long runs of cable are generally not a great idea if you are relying on a voltage signal. The datasheet for it (The one I have is from the Texas Instruments website), has a few strategies to reduce this problem somewhat.

The approach that I have used successfully, is to use a current signal, rather than a voltage signal. This has the advantage that you only need a two wire twisted pair cable (I made my own twisted pairs - it is easy for relatively short runs).

The idea is that you connect the LM35 output to the ground pin with a known resistor value (the datasheet example has a 200 Ohm resistor). Since the voltage is 10mv per degree, the current wil be 10/R mA per degree. There will be an additional small current from the LM35 device itself, but this is small, and almost constant. Then connect the supply and ground to one end of your twisted pair.

At the other end, it is necassary to convert the current signal back to a voltage so that your Arduino can read it. Simply put a resistor (again, 200 Ohms is that used in the datasheet example) between the low side of the twisted pair to OV, the high side connected to 5V, and measure the voltage across this resistor.

Figure 17 in the TI datasheet is the one to follow.

Other things that help to get more stable, acurate readings;

Choose a time to take readings when you are not running anything else that might interfere (wireless comms, ultrasonic sensors, motors, solenoids, etc).

Take several readings. Ignore the first two.

Take the median value of the remaining readings (eg take 5 readings, ignore the first two, and sort the others in order. Then take the middle value.).

Hope this helps.

0

Short answer

Add delay between each reading, 100ms should be enough.

Long answer

The LM35 is an analog device and you are using the internal ATmega328 ADC to read the voltage on the signal pin. The way the Arduino ADC works is a sample-and-hold process:

  1. open a circuit to an internal capacitor
  2. charge the capacitor
  3. disconnect the circuit
  4. compare capacitor to the reference voltage

Because there is only one of such circuits shared among all the 6 analog pins you need to let the capacitor charge up, which is much slower on long lines having a non negligible resistance and also a non negligible capacitance.

Also other wires and power lines near to your ethernet cable are going to influence your readings, but in that case the ethernet cable shielding is going to help you, if properly used.

1
  • Thanks a lot, I will try this as soon as I get back to the setup.
    – gabelach
    Commented Sep 5, 2016 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.