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.