Sensor Readings Fluctuating

So, I did my best to scour the forumns for a solution to this problem and there are a few solutions that helped reduce fluctuations but not eliminate them:

  1. Space pins apart, e.g. 1,4,6
  2. Call the the pin, then pause and read
  3. Use external power source to provide more consistent voltage. Arduino was putting out 4.6V but now is putting out 5.03V consistently.

As a result of these adjustments, fluctuations decreased from +/- 14 to +/- 2.5 Any ideas why the code is doing this? I am using the SCA100T sensor and since it is a leveling sensor, it needs to be consistent. See spec sheet for more info if you want:

http://www.muratamems.fi/sites/default/files/documents/sca100t_inclinometer_datasheet_8261800a.pdf

Code:

const int XIN = 0;//assigns pin to X AXIS
const int YIN = 1;//assigns pin to X AXIS
int xAxis = 0; int yAxis = 0;//assigns initial value to variable 'xAxis' and 'yAxis'

void loop() {

analogRead(XIN); //Calls pins attention to arduino
delay(25); //Waits for pin, reduces noise
xAxis = analogRead(XIN); //reads X AXIS for input
analogRead(YIN); //Calls pins attention to arduino
delay(25); //Waits for pin, reduces noise
yAxis = analogRead(YIN) ;//reads X and Y AXIS for input

Serial.print("X AXIS: ");Serial.print(xAxis);Serial.print('\n');
Serial.print("Y AXIS: ");Serial.print(yAxis);Serial.print('\n');

delay(1000);
}

This is the page for the SCA100T inclinometer sensor: http://www.muratamems.fi/en/products/inclinometers/sca100t-inclinometers
This sensor has two analog outputs and it is working in measurement mode at startup.
The SPI interface is used to control it, but without SPI the chip is already working.

There is no need to wait between reading X and Y.
There is no such thing as "calling the pin".
This sensor has a high accuracy and is very sensitive. So some noise is normal.

So your +5v is now stable, that's good.

My suggestions:

  • Us 100nF at the sensor. At the +5V and GND for supply voltage decoupling.
  • Place the sensor on a concrete floor, or something very stable. Not a wooden table.
  • Take the average of a number of samples (for example 3...25 samples). Using the average of multiple samples is very normal, it's even normal for high quality sensors.
int n, xRaw, yRaw;
int xAxis, yAxis;

xRaw = 0;
yRaw = 0;
for (n=0; n<20; n++)
{
  xRaw += analogRead(XIN);
  yRaw += analogRead(YIN);  
}
xAxis = xRaw / n;
yAxis = yRaw / n;