Stabilize the signal of a sensor connected to my nodeMCU


After reading a lot and a few questions answered in this forum, I managed to make my sensor working. It's a pressure transmitter (piezometer) which output 4-20mA (corresponds to 0-10m).
I did it this way:

I have a 2 converters:

  • for the 12V:
  • for the 5V:

My only issue now is that the signal is not super stable. It's not a big deal but during my tests, I'm not moving the sensor but the results can vary by 1 to 3 cm between each measurement. For each of them, I read the analog 10 times (with 200ms delay) and average them.

I would like to know if there's a way to make the signal more stable.

Thank you again for your help

moving average filter

simple Kalman filter

What is the sensor?
Link to data/specs please.

results can vary by 1 to 3 cm between each measurement

With respect to what maximum value?

Have you tried lowering the 10K series input resistor?
If the voltage across the shunt resistor doesn't go above the Node MCU Vcc, you may not need it at all.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

So 16mA = 10m i.e. 1.6mA/meter. At 250R this is 400mV per meter or 4mV per cm. You say you have an error of 1 ~ 3cm per measurement; this is 4 ~ 12mV. I congratulate you; that's a very good achievement for this simple setup!!

@Idahowalker Thanks for these interesting links. My goal here is to find a way, if possible, to stabilize the signal in my scheme before using these filters. I didn't know these libraries exist and I will definitely use them.

@TomGeorge Sorry, I should have put the link:

I should have write it more explicitly: 4mA is 0 m and 20mA is 10 m. I was measuring 1.8 m at that time. 3cm doesn't seem to be a lot but I'm just trying to be as stable possible.

Will try that and will let you know if anything good happened.

Thanks to both of you!

ESP8266 ADC Tutorial | NodeMCU ADC for Analog Input Arduino IDE (
From the article --

250 ohm is for 5volt processors, which the NodeMCU is not.
It must be changed to 160 ohm for this 3.3volt processor.

The 10k resistor has no function on a NodeMCU, and can be removed.
Because the NodeMCU has a voltage divider on the analogue pin.

Yes, I remember the 160 ohm Leo. Sorry, I forgot to change the value in the scheme.
Thanks for the info for the 10k resistor.