Noise on Analog Inputs

Tags: #<Tag:0x00007fe22013fb50>


Hi guys,

I have 5 capacitive humidity sensors hooked on A0 … A4 but I can’t read anything due to extreme levels of noise (I have and antenna and a switching power supply in my circuit).

What is the recommendation in this case? Small capacitor to the ground?



@felipe1, which capacitive humidity sensors specifically? Can you also describe your board design?


hi @peekay123, thanks for coming for the rescue.

This is the sensor I’m using:

If I disconnect the sensors and read the AI’s all I see in random noise. When I connect the sensors it’s not that different.

My photon controls a 12VDC 8 relay board based on the readings of the AI’s. Inside my junction box I have 2 switching PS (one 5VDC and the 12 VDC).


When the Sensor isn’t connected, you will get random ADC values.

I’ve used those capacitive sensors for soil moisture monitoring in the past.
I calibrated my Code with (2) const int values, one for Air, and one for Water (actual ADC readings for both media). Then map your future readings between these (2) const int’s.

The following were my actual calibrations for a 10-bit ADC, but this shows that without knowing the endpoints, the ADC readings from these sensors aren’t very useful:

const int AirValue =   593 ;      // replace this value with Value_1
const int WaterValue = 278 ;    // replace this value with Value_2

You might be way past this in your project, if so I apologize.


Hi Rftop, thanks for your message.

Unfortunately that is not my case, if I connect the sensor straight to the photon I have stable reading. The problem is when I connect the sensor using a 2 meter cable.

I’ve just added an RC filter to it (8pF and 1k) but it didnt do much. It’s not a real time application so I’m thinking of collecting 100 readings and taking the average to see if I can get rid of the noise.


Ahhh, I used a weatherproof version of shielded Cat5 Twisted cable to monitor a few deep borings.
Maybe something similar will help for your project?


It could be an option. What I don’t understand is that I’ve used the same cable but with an arduino and it worked. I switched to particle so I could expose the variables to the cloud.

I’m getting completely random readings (note that I did not map the values):


Does your cable have a bare wire in it (no insulation) if so, use that as a drain, connect it to ground on the photon side, and leave it disconnected on the other end.


Hmmmm… well my only other guess is that cable is now picking up RF energy from the Photon’s WiFi.
If so, the shielding and/or drain “should” help.


What Arduino?
Most “legacy” Arduinos use 5V as Vref and only 10bit resolution so any noise would be less prominent and AVRs also use a different kind of ADC and have higher input impedance (IIRC).


@ScruffR Uno I guess I got used to the noise forgiveness of arduino’s ADC and tried to do the same. What do you think about adding a voltage follower to each AI?

@Rftop and @Mjones Thanks guys, I’ve changed the cable for a shielded one and it drastically improved the reading stability


@felipe1, that analog moisture sensor uses a frequency to voltage circuit using a 555 timer as the frequency generator and a basic RC integrator to produce the voltage. This frequency to voltage approach will yield some ripple on the voltage values. Your code should perhaps take several measurements and calculate an average to reduce the effect of noise. You could even apply a digital low-pass filter (lots of libraries available) to target noise more specifically.

The RC has a 1M resistor coupled with a 1uF capacitor which creates a relatively high impedance circuit while the Analog inputs on the STM32 are lower impedance. Using a voltage follower would remove the impedance issue but may be overkill for your application.


@peekay123 Thanks for the advice! I implemented a quick LPF (cut frequency = 100Hz) and I’m really happy with the results.

The shield and the filter were great suggestions, thanks guys!