ADS1115 Spikey Sporadic Data

Hi there,

i am doing a project using ADXL335 accelerometers, a linear potentiometer and a hall sensor, running on an arduino due. Because i am using 5 accelerometers, each with 3 outputs, i ran out of space. T|o solve this i bought an ADS1115 analog to digital convertor. When i run it, i am getting data spikes. \i have attached an image of what i mean. i have tried using adifferent accelerometer, a new ADS1115, but am yet to try swapping wires to see if that’s the issue. I was wondering if anyone had run into this before and knew the issue/ cause. I have also added my code below.

/* ADXL335 single accelerometer test file
 *  
 *  uses ;
 *  
 *  A0 - X axis
 *  A1 - Y axis
 *  A2 - Z axis
 *  5V - Vcc
 *  Gnd - Gnd
 *  
 */
#include <Wire.h>
#include <Adafruit_ADS1015.h>
 
Adafruit_ADS1115 ads1115;
float Front_Pot;

  int16_t  adc0, adc1, adc2, adc3, adc4;

 // Accelerometer 1
const int Xpin_1 = A2;
const int Ypin_1 = A1;
const int Zpin_1 = A0;

 // Accelerometer 2
const int Xpin_2 = A5;
const int Ypin_2 = A4;
const int Zpin_2 = A3;

 // Accelerometer 3
const int Xpin_3 = A6;
const int Ypin_3 = A7;
const int Zpin_3 = A8;

 // Accelerometer 4
const int Xpin_4 = A11;
const int Ypin_4 = A10;
const int Zpin_4 = A9;

 // Accelerometer 5
const int Xpin_5 = adc3;
const int Ypin_5 = adc2;
const int Zpin_5 = adc1;

const int button_in=3;
bool button_state=false;

const int Hall_Sensor=9;
int Hall_Voltage;

unsigned long timeMicro;

float X1_ZeroG = 348.5;
float X1_scale = 70.5;
float Y1_ZeroG = 351.5;
float Y1_scale = 71.5;
float Z1_ZeroG = 362.5;
float Z1_scale = 70.5;

float X2_ZeroG = 346.5;
float X2_scale = 69.5;
float Y2_ZeroG = 342.5;
float Y2_scale = 70.5;
float Z2_ZeroG = 359.5;
float Z2_scale = 70.5;

float X3_ZeroG = 345;
float X3_scale = 71;
float Y3_ZeroG = 347;
float Y3_scale = 70;
float Z3_ZeroG = 363;
float Z3_scale = 71;

float X4_ZeroG = 338.5;
float X4_scale = 67.5;
float Y4_ZeroG = 330;
float Y4_scale = 69;
float Z4_ZeroG = 355;
float Z4_scale = 70;

float X5_ZeroG = 342;
float X5_scale = 69;
float Y5_ZeroG = 345;
float Y5_scale = 70;
float Z5_ZeroG = 352;
float Z5_scale = 71;


#include <SPI.h>
#include <SD.h>

File myFile;



void setup() {
  // put your setup code here, to run once:
Serial.begin(115200);

ads1115.begin();

      pinMode(button_in, INPUT_PULLUP);


  Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  myFile = SD.open("testDUE.txt", FILE_WRITE);

pinMode (Hall_Sensor, INPUT);
}

void loop() {


  adc0 = ads1115.readADC_SingleEnded(1);
  adc1 = ads1115.readADC_SingleEnded(2);
  adc2 = ads1115.readADC_SingleEnded(3);
  adc3 = ads1115.readADC_SingleEnded(0);
timeMicro = micros();

  
button_state = digitalRead(button_in);
Hall_Voltage = digitalRead(Hall_Sensor);
        
        if (myFile) {


        // Time-keeping
        Serial.print(timeMicro/1000000.0, 6);
        myFile.print(timeMicro/1000000.0, 6);

        //Hall Sensor
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(Hall_Voltage);
        myFile.print(Hall_Voltage);

        //Front Potentiometer
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(adc3*(6.85/5)*(75/32768.0),2);
        myFile.print(adc3*(6.85/5)*(75/32768.0),2);
        
        //Accelerometer 1
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(analogRead(Xpin_1));
        myFile.print(analogRead(Xpin_1));
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(analogRead(Ypin_1));
        myFile.print(analogRead(Ypin_1));
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(analogRead(Zpin_1));
        myFile.print(analogRead(Zpin_1));

         //Accelerometer 2
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(analogRead(Xpin_2));
        myFile.print(analogRead(Xpin_2));
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(analogRead(Ypin_2));
        myFile.print(analogRead(Ypin_2));
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(analogRead(Zpin_2));
        myFile.print(analogRead(Zpin_2));

         //Accelerometer 3
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(analogRead(Xpin_3));
        myFile.print(analogRead(Xpin_3));
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(analogRead(Ypin_3));
        myFile.print(analogRead(Ypin_3));
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(analogRead(Zpin_3));
        myFile.print(analogRead(Zpin_3));

         //Accelerometer 4
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(analogRead(Xpin_4));
        myFile.print(analogRead(Xpin_4));
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(analogRead(Ypin_4));
        myFile.print(analogRead(Ypin_4));
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(analogRead(Zpin_4));
        myFile.print(analogRead(Zpin_4));


         //Accelerometer 5
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(adc2);
        myFile.print(adc2);
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(adc1);
        myFile.print(adc1);
        Serial.print("\t");
        myFile.print("\t");
        Serial.print(adc0);
        myFile.print(adc0);

         // Line Termination
        Serial.println();
        myFile.println();
        }

    if (button_state==LOW){
      myFile.close();
      delay(250);
      Serial.println("done.");

}
}

Thanks

Ross