Analog To Digital Sensor - Tune or sharpen the voltage reading to improve accuracy

We have a Analog To Digital Sensor (adc) on a ESP32. We would like to sharpen the voltage readings to make it more accurate. We have medium in our code that is helping so we are all good there. We are wondering if anyone has managed to sharpen their reading by ether by adding in resistor, capacitor or anything into their wiring that helps sharpen the voltage range.

This is our voltage readings without changing anything and ranges from 0.47V to 0.58V.

I am using a 10k thermistor and found putting a 100nf capacitor across the thermistor made a big difference. I used a spread sheet to graph the readings without the capacitor - and then slipped the capacitor into the bread board and added the new readings.

I canā€™t remember the exact readings, but where I was getting something like +/- 0.3v, it immediately dropped to something like +/- 0.15. The flattening of the graph was very noticeable. For less than a dollar it is more than worth it.

1 Like

Hi @Steve61 thanks for the info :+1:ā€¦ i am going down that path now and have 4 ESP32 on test for about 5 hours. One seams to be a bit radical and the other 3 seam to sharpen up.

Voltage2

I am a long way from an expert user, but I have also read that if you are using long leads on some sensors, it is best to use twisted pairs to avoid interference. (eg some old cat5 ethernet cable.)

The three you have flat look good.

Yeaā€¦ at the moment they are in a bread board on testā€¦the 3 are +/- 0.05 but it early days as I really need 24 hours. Your capacitor is wired is from the data to neutral?

Yes - from the data leg (before the resistor which goes to the 3.3v). So effectively it is going from the ADC to GND on the board. I have seen some people suggesting it goes from 3.3v to signal (ADC) but I havenā€™t tried that.

Yep I have done the sameā€¦ thanks mate really good to know I going down the right track. :+1: :grinning:

What is the [source of] signal that youā€™re measuring, and how often should it vary?

Knowing that might prompt some more ideas for smoothing it. (assuming smoothing it is what you want)
There will also always be some random fluctuation in readings, even on a stable input signal, due to various things that canā€™t be controlled such as thermal noise generated within the ESP itself, and timings of the ADC sampling.

@glyndon thanks for the chatā€¦ we are on a attenuation: 11dbā€¦ I have already got a median that read 60 inputs over 10m and give the averageā€¦ that has help heaps and really its fine for what I am doingā€¦ but my curious mind is trying to go to the next levelā€¦ not sure if anyone is an expert on ā€œlead compensator RCC circuitā€ my wholesaler reckons I should study that but not sure if that is correct.

If your data goal is the average over a span of minutes, what is the motive for smoothing the signal over short intervals?

And yes, I believe to design a proper [R/L]C network to compensate for the signal path, one would first have to know all the physical specs of that path.
e.g., 11dB attenuation of ā€¦ what?

I have these pressure sensors

Since the ADC can accept only up to 3.3v, how have you reduced the 0.5-5v output of the sensor?
Typically, all youā€™d need is a simple voltage divider, with your output going to the ā€˜topā€™ of it, and the ADC on the ā€˜centerā€™ tap, and the ā€˜bottomā€™ to ground.

I have calculated the size of my pressure sensor I needed so my range is from what you see above to around 2.8vā€¦ everything works perfectly and surprising very accurateā€¦ I am just anal trying to see if I can sharpen the signal so the readings stay pretty consistent. It is not critical just seeing if I can figure this out / learn more.

You may appreciate looking again at the difference between precision and accuracy.
Iā€™ve never heard the term ā€˜sharpenā€™ applied to a signal, unless perhaps you want more detail (usually associated with precision) than less.

From this thread, I think you would like to see less detail (i.e. less precision in timelines < seconds), while being assured of accuracy (over timelines in the range of minutes).

With your mathematical smoothing, youā€™re already achieving that goal. Smoothing the analog line wonā€™t make any difference to your stated goal.

Hmmmm same same
precision = the quality, condition, or fact of being exact and accurate.
accuracy = the quality or state of being correct or precise.

It is just an english word
sharpen = improve or cause to improve.

The ESP32 ADC can be sensitive to noise leading to large discrepancies in ADC readings.The question isā€¦ now you know what sharpen means (improve)ā€¦ so improve the discrepancies in ADC readings

With my current test I am achieving my goal (sharpen the voltage range) and it is making a difference.

Not sure if you are contributing to this thread. Thanks for your help anyway.

I learned (about 50 years ago, so it may have changed) that precision was how detailed was a datum
(e.g. 3.141592765 was more precise than 3.14) and that accuracy was that if the temperature is 54, then the datum was also 54 (and not 48, 57, etc). Precision and accuracy can exist without the other. Ideally, we want both.

In this case, you presumably do have accurate data - itā€™s telling you the pressure, correctly.

However, Iā€™ve never heard the term ā€˜sharpenā€™ applied to data before. You define it as ā€˜improveā€™, but to achieve that one needs to qualify what aspect of it is to be ā€˜improvedā€™, and how.

If one adds detail (ie. precision) to a dataset the outcome is a ā€˜jaggierā€™ curve if plotted on a chart.
But you seem to want the curve to be smoother, which would actually make it less precise (and less accurate over short intervals, as it would not be tracking the input as closely). Is less precise an improvement?

So, out of an abundance of confusion I must apologize that I can be of no assitance here, as Iā€™m unable to understand your goal.