I’m building a sensor net for our house; I’m using Arduino and XBee and these thermistors: http://www.sparkfun.com/products/250. They work relatively well when connected directly to the board and because I’m only measuring current to compute temperature, I can connect them directly to XBee on the sensor side (don’t need arduino there). But when I connect them using a long wire (10 - 20 feet) things get really weird. For people who have more experience with electronics this might not be surprising, but these are the things I’m seeing:
- sometimes, the measurements over a long wire have very little noise (<0.1 oC)
- sometimes what I get looks like actual noise (ie, random oscillations around a certain value), but sometimes the measurements form a “zig-zag” line. I’m measuring every 5 seconds, and for 30 seconds, the values increase, then for 30 seconds decrease (the difference between top and bottom is 2oC)
- I have a sensor connected over a long wire, but the actual sensor is right next to the board (so I’d expect same temperature) and I’m getting (average) 18oC, then I replace it with sensor connected directly to the board and I’m getting 22oC. this seems like too much error to come from the resistance on the wire
- finally, I have a board with 2 directly connected sensors and 1 over a long wire (but same location). the two directs are giving me both 21oC, but the wired one is 18oC. then I replace the wire with another directly connected sensor and this actually changes temperature of all sensors – now all sensors are showing 20oC
Anyway, there’s just too much unpredictability in this to use for actually measuring temperature.
Any suggestions? Is there a way to handle the noise, but still use these thermistors? I’m thinking about buying different sensors, but the advantage of these is that I can connect directly to XBee and send measurements without Arduino on the sensing end.
I appreciate any feedback!
Are your long leads separate wires for the two sensor leads. If so then you will induce noise into your system since each leads picks up differing noise signals… One technique for noise elimination is to permit common mode noise (induced into both leads) which effectively cancels itself. Simply twisting the wires tightly together (using either a hand or electric drill) will provide a high degree of noise cancellation.
Try to install a cap, at the inputs of the board. The bigger, the better, only quality of electrolytic should be good, may be tantalum with minimum leakage current
I tried twisting the wire, but it doesn't seem to help much.
How exactly do I connect the capacitor? I have no experience with that ... I'm ordering some stuff from SparkFun soon; would one of these work http://www.sparkfun.com/products/8375?
I suppose that you have thermistor connected between +5V and analog input and 10 k resistor between analog input and ground. Try to connect 15 k variable resistor (trimmer potentiometer) between analog input and ground instead 10 k resistor. Place your project as you wish and try to adjust real temperature with potentiometer. This must work.
There are two ways to deal with noise: The hardware and the software solution.
The hardware solution is a lowpass filter which can be materialized in lots of different ways. The simplest solution is an RC lowpass filter. This consists of a series resistor and a capacitor in parallel. You can try more sophisticated implementations like RLC filters or active filters with op amplifiers (but only if you are demanding). I believe you should opt for a filter with a cut-off frequency of approx. 10kHz; In that case according to this online calculator you have to pick a 2.7Ohm resistor and a 4.5?F capacitor. You can also try a simple RLC Chebychev filter. For a starter I would suggest that you try to simply connect a 4.7?F capacitor in parallel and a 2.7Ohm resistor in series while twisting the cables as mentioned above (You can buy cable in twisted pairs).
The software solution is based on smoothing algorithms like Moving average, exponential smoothing or other. You can find a list of some of them here.
I believe you should opt for a filter with a cut-off frequency of approx. 10kHz;
It's too much, for temperature measurements cut-off should be a few Hz. There is no need for serial resistor, as thermistor itself part of RC filter.
Nothing difficult in connecting cap to input, negative pin goes to ground and positive to input. Value for 1 Hz: C = 1 / 2 x Pi x F x R (10 k) = 15.9 uF
I like the idea filtering out noise in software, better also to "over-sample" input signal, let say take measurements every 0.1 seconds, than run overage for 10 samples. Capacitor could be lower in this case, as it's in reverse proportion to sampling frequency frequency.
Another benefit of over sampling a slow moving signal is higher accuracy/resolution via decimation. Here, noise may actually help you achieve higher accuracy. (depends on amount of noise, naturally) see the atmel paper on this topic, it's quite enlightening.
I definitely considered (and I am using) software smoothing, but the “noise” doesn’t seem to be with mean = 0. See the bullet #4 in my original post; replacing long wire with a direct thermistor has significant impact on the temperature of that sensor and also of other sensors connected to that board. Also, take a look at green line on the attached plot. It was first measuring using a long wire and then was replaced by direct thermistor (on same location). First, the noise seems to be of a much lower frequency (1/60 Hz?) and using the direct connection changed the temperature significantly.
In the plot, the blue line is another thermistor connected over a long wire, but directly to Arduino (not to XBee) and there the noise seems lot more like an actual noise. Not sure why it’s behaving differently.
I’ll try connecting the capacitor and see what I get.
I definitely considered (and I am using) software smoothing, but the "noise" doesn't seem to be with mean = 0.
This what I'd expect, with
interference 60 Hz from electrical grid noise is not follow Gaussian math. But oversampling / averaging still would help to decrease variation when sampling frequency isn't a multiple of interference. Best of all, probably, take a samples with random delay, let say 100 millisec - 200 millisec, or implement software notch filter.
Regarding "off-set" you have in two measurements, it's symptom of great non-linearity presents:
ADC input is non-linear. Solution: hardware filter, before signal get to input.
Averaging is done after non-linear equation (with thermistor cubic polynomial?) Solution: only raw samples must be averaged. I'm guessing here, could you confirm that you've made this mistake, and average output results?
One explanation for the noise having a DC component is RF pickup... Radio frequency interference itself wouldn't be visible, being above the response frequency of the ADC, but often you'll find part of the circuit (such as a diode or transistor) acts as a "detector", effectively performing AM demodulation on the radio frequency signal and converting part of it to a DC offset.
Long wires can act as an efficient antenna, picking up surprisingly high RF voltages (especially if you are close to a broadcast transmitter). The cure is simple, a ceramic capacitor across the sensor wires at the Arduino end (1000pF is probably enough). Sometimes a ferrite bead or toroid over both wires can help too. Google "RFI" perhaps?
Twisting the wires didn't help much, but adding the capacitors completely resolved the issue! Thanks a lot for all the comments!