First of all, i'll apologise for not showing my attempted code as i typed this on my mobile device.
I am reading multiple voltages from a DC source but the ADC values are a mess, jumping high and low.
I found the IDE Inbuilt "Smoothing" example and would like to implement it in my code.
My problem is i don't know how to port it into my current "multiple readings" code.
Hope i am clear enough to get help.
Thanks in advance.
gcjr
May 3, 2024, 9:55am
3
sounds like a wiring issue if values are fluctuating significantly with a DC input
gcjr
May 3, 2024, 9:57am
4
i read recently that there may be only one ADC that is switched between ports and when reading a different port the port should be read twice and the 1st reading ignored
First, do this:
rawvalue = analogRead(A0);
rawvalue = analogRead(A0);
The first read "preconditions" the ADC, and the second read will be much more accurate.
If that's not helping enough, put at the top of your code:
int rawvalue;
const int factor = 8;
and in the body of your code:
rawvalue = analogRead(A0);
rawvalue = analogRead(A0);
avgvalue = rawvalue/factor+(avgvalue*(factor-1))/(factor);
You can adjust the smoothing factor easily. YMMV, depending on the code you haven't shared.
1 Like
jim-p
May 3, 2024, 11:39am
6
Then it's a hardware issue.
Trying to fix it in software will be a waste of time.
2 Likes
system
Closed
October 30, 2024, 11:40am
7
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.