Pages: [1]   Go Down
Author Topic: Stabilize analogRead?  (Read 1659 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Lefty
Logged

0
Offline Offline
Shannon Member
****
Karma: 201
Posts: 11744
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, almost certainly you didn't common the grounds - you can't measure anything if there isn't a reference point.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

:hangs head, walks back into corner:

Thanks,
Chad
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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

Rob Tillaart

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

Pages: [1]   Go Up
Jump to: