Peaks and Dips in HIH-4030 Humidity Sensor Readings

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?

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?

Cable is approximately 6 inches long.

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.

Docedison:
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?

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.

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

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.

Looks like ADC noise might indeed be the reason I'm getting unstable readings.

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

I'm not disputing the remedy. Just suggesting there may indeed be nothing wrong with the sensor after all.

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.

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.