Offline
Newbie
Karma: 0
Posts: 38
|
 |
« on: May 09, 2012, 02:09:40 pm » |
Using Sparkfun's HIH-4030 Breakout with my Arduino Mega, I'm getting occasional dips and peaks in the sensor's humidity readings. The dips and peaks can be as high as 10% humidity and are brief enough that they're almost certainly noise rather than signal. I've tested the Arduino itself for noise in its 5V rail and it seems to be working fine. Are these dips and peaks to be expected with this sensor, or is there likely something wrong with mine?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 71
Posts: 6617
Arduino rocks
|
 |
« Reply #1 on: May 09, 2012, 05:20:21 pm » |
Interestingly the datasheet seems to make no mention of the output impedance of the sensor. Stick a 10nF cap between its output and ground perhaps to reduce noise?
Is the sensor close to the board or at the end of a long cable?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 38
|
 |
« Reply #2 on: May 09, 2012, 05:38:34 pm » |
Cable is approximately 6 inches long.
|
|
|
|
|
Logged
|
|
|
|
|
Anaheim CA.
Offline
Edison Member
Karma: 31
Posts: 2304
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #3 on: May 09, 2012, 08:36:05 pm » |
You might also look at the history (averaging) of the sensor output and discard one of a kind readings. The other thing I would recommend is a 1 - 10uF cap across the Vcc... Right AT the Sensor. Frequently spikes on the Vcc source are too fast and non periodic, so measuring them presents a real challenge unless you are really good with a high speed O'scope and even then there are ground induced currents that flow in the scope ground lead that will make trapping that kind of problem a great deal more difficult, especially if you are trying to measure the 'noise' while connected to the PC's USB port. I won't go into the reasons why here... Long and sometimes difficult to explain why you see noise on the ground lead. It is called common mode noise and apparently is "On the supply rail"... it isn't but any voltage impressed on the ground circuit must be in the hot lead as well... , or it''s mirror (opposite).
Doc.
|
|
|
|
|
Logged
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 38
|
 |
« Reply #4 on: May 09, 2012, 10:43:05 pm » |
Frequently spikes on the Vcc source are too fast and non periodic, so measuring them presents a real challenge unless you are really good with a high speed O'scope ...
So Vcc spikes could be acting as impulses, producing obvious spikes in the humidity sensor's output that cannot be so easily detected when sampling Vcc directly?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 38
|
 |
« Reply #5 on: May 10, 2012, 12:31:05 pm » |
I've gone ahead and ordered another of the same sensor. I'm curious to find out whether the noise I'm getting has anything at all to do with a faulty sensor.
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Online
Tesla Member
Karma: 90
Posts: 9396
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #6 on: May 10, 2012, 01:50:14 pm » |
This could be a way to value = measureHumidity(); if (Math.Abs(value - previousValue) > (previousValue/20)) // changes > 5% (= 1/20) are considered noise { value = previousValue; } else { previousValue = value; }
or use a low pass filter that automatically filteres outliers ...
value = value - 0.15 (value - measureHumidity()) ;
other options include runningAverage() and runningMedian() -> see playground
|
|
|
|
|
Logged
|
|
|
|
|
Anaheim CA.
Offline
Edison Member
Karma: 31
Posts: 2304
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #7 on: May 10, 2012, 07:51:19 pm » |
You Might also try Bypassing the device, At the Device... Try a 1uF Ceramic cap... for starters up to 10uF should killl any spikes right at the sensor.
|
|
|
|
|
Logged
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 38
|
 |
« Reply #8 on: May 11, 2012, 03:05:36 pm » |
Looks like ADC noise might indeed be the reason I'm getting unstable readings.
|
|
|
|
|
Logged
|
|
|
|
|
Anaheim CA.
Offline
Edison Member
Karma: 31
Posts: 2304
Experienced old Whitebeard with a Full head of Hair...
|
 |
« Reply #9 on: May 11, 2012, 04:48:12 pm » |
Yeah, it's real simple... call it "insurance" against a "Potential" problem... If Ya Got THe By Pass Caps installed then YOU KNOW it is very unlikely to be noise on the Vcc source. Most ALL digital devices CAN create noise so buy some CHEAP insurance... after ALL exactly how much will a handful of small caps (.1 and 4.7uF) caps cost. On a breadboard... they are child's play to insert right where the device is powered, they ARE reusable and what's worse they are just "Common Sense"..
Doc
|
|
|
|
|
Logged
|
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 38
|
 |
« Reply #10 on: May 11, 2012, 05:07:08 pm » |
I'm not disputing the remedy. Just suggesting there may indeed be nothing wrong with the sensor after all.
|
|
|
|
« Last Edit: May 11, 2012, 05:09:02 pm by AdrianLopez »
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 71
Posts: 6617
Arduino rocks
|
 |
« Reply #11 on: May 11, 2012, 05:18:20 pm » |
I don't believe you said how you are powering the Mega - USB or Vin + on-board regulator? On-board regulator is likely to be much cleaner.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 38
|
 |
« Reply #12 on: May 11, 2012, 05:37:23 pm » |
I've been powering the Mega via the USB plug, but yesterday I tried the AC adapter and still got some noise. I didn't do any statistical tests to know whether it made any difference, but it did seem slightly less noisy when using the adapter.
|
|
|
|
|
Logged
|
|
|
|
|
|