Go Down

Topic: Stabilize analogRead? (Read 1 time) previous topic - next topic

HKChad

I am using a SCA121T-D03 sensor and the values I am getting from analogRead are all over the map. How should I hook this up so I can get stable readings? I am able to get stable readings from my multimeter no problem but not in arduino. Since this sensor takes 7-35 volts I am powering the sensor w/ an external 12v battery, the arduino is powered via USB and I have the input wires hooked to A1 and A2. Simply doing this,

  int xVal = analogRead(1);
  int yVal = analogRead(2);
 
  float volX = xVal*5.0/1024;
  Serial.print("volX = ");
  Serial.println(volX);

in a loop produces,
volX = 0.81
volX = 0.90
volX = 2.30
volX = 3.31
volX = 3.93
volX = 3.82
volX = 2.98
volX = 1.64
volX = 0.79
volX = 1.09
volX = 2.54
volX = 3.57
volX = 4.01

w/ a delay(1000) between. How can I have this produce 2.5 when sensor is a rest (0*) like my multimeter? I have tried averaging 10 samples over 1 second and that didn't help much still produced very high highs and very low lows.

Thanks,
Chad

retrolefty

Did you remember to have a wire connection between the external 12 volt negative and a arduino ground pin, that is required?

Lefty

MarkT

Yes, almost certainly you didn't common the grounds - you can't measure anything if there isn't a reference point.
[ I won't respond to messages, use the forum please ]

HKChad

:hangs head, walks back into corner:

Thanks,
Chad

delirii

Make sure also your power source is stable enough, maybe add some kind of filter (low pass) at the exit of your sensor, and, you can add some kind of "moving average" function to get a stabilized value.

robtillaart


check - http://www.arduino.cc/playground/Main/runningAverage - for different techniques
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up