ADS1219, Using Several Ain Pins

I just seem to be full of problems with this project…

Working with a 3-axis accelerometer, wiring x, y, and z into the 1219’s pins Ain0, Ain1, and Ain2. Pull-up resistors are in place at Ain0, Ain1, and Ain2.

All of my ADC “reads” seem to only be seeing Ain1.

It’s probably a simple mistake… Please help?

#include <SparkFun_ADS1219.h> // Click here to get the library: http://librarymanager/All#SparkFun_ADS1219

SfeADS1219ArdI2C myADC;

void setup() {

// put your setup code here, to run once:

delay(1000); // Allow time for the microcontroller to start up

Serial.begin(115200); // Begin the Serial console

while (!Serial)

{

delay(100); // Wait for the user to open the Serial Monitor

}

Wire.begin(); // Begin the I2C bus

// Initialize ADC - this also performs a soft reset

while (myADC.begin() == false)

{

Serial.println("ADC failed to begin. Please check your wiring! Retrying...");

delay(1000);

}

// Configure the input multiplexer. Options are:

// ADS1219_CONFIG_MUX_DIFF_P0_N1 (Default)

// ADS1219_CONFIG_MUX_DIFF_P2_N3

// ADS1219_CONFIG_MUX_DIFF_P1_N2

// ADS1219_CONFIG_MUX_SINGLE_0

// ADS1219_CONFIG_MUX_SINGLE_1

// ADS1219_CONFIG_MUX_SINGLE_2

// ADS1219_CONFIG_MUX_SINGLE_3

// ADS1219_CONFIG_MUX_SHORTED

//myADC.setInputMultiplexer(ADS1219_CONFIG_MUX_SINGLE_0); // Read the voltage between AIN0 and GND

Serial.println(“ADC initialized”);

Serial.println(“Reading the voltage through the input multiplexer”);

}

void loop() {

myADC.startSync(); // Start a single-shot conversion.

while (myADC.dataReady() == false) // Check if the conversion is complete. This will return true if data is ready.

{

delay(10); // The conversion is not complete. Wait a little to avoid pounding the I2C bus.

}

myADC.setInputMultiplexer(ADS1219_CONFIG_MUX_SINGLE_0); // Read the voltage between AIN0 and GND

myADC.readConversion(); // Read the conversion result from the ADC. Store it internally.

float milliVolts0 = myADC.getConversionMillivolts(); // Convert to millivolts.

Serial.print("ADC voltage Ain0 (mV): ");

Serial.println(milliVolts0, 6); // Print milliVolts with 6 decimal places

myADC.setInputMultiplexer(ADS1219_CONFIG_MUX_SINGLE_1);

myADC.readConversion(); // Read the conversion result from the ADC. Store it internally.

float milliVolts1 = myADC.getConversionMillivolts(); // Convert to millivolts.

Serial.print("ADC voltage Ain1 (mV): ");

Serial.println(milliVolts1, 6); // Print milliVolts with 6 decimal places

myADC.setInputMultiplexer(ADS1219_CONFIG_MUX_SINGLE_2); // Read the voltage between AIN0 and GND

myADC.readConversion(); // Read the conversion result from the ADC. Store it internally.

float milliVolts2 = myADC.getConversionMillivolts(); // Convert to millivolts.

Serial.print("ADC voltage Ain2 (mV): ");

Serial.println(milliVolts2, 6); // Print milliVolts with 6 decimal places

delay(250);

}

As it sits, the accelerometer is tilted on the y axis, so Ain1 should be ~465, and Ain0 and Ain2 should be ~388.

@RJTristani1

You need to start a single-shot conversion and read the result for each input / axis:

  myADC.setInputMultiplexer(ADS1219_CONFIG_MUX_SINGLE_0); // Read the voltage between AIN0 and GND

  myADC.startSync(); // Start a single-shot conversion.

  while (myADC.dataReady() == false) // Check if the conversion is complete. This will return true if data is ready.
  {
    delay(10); // The conversion is not complete. Wait a little to avoid pounding the I2C bus.
  }

  myADC.readConversion(); // Read the conversion result from the ADC. Store it internally.

  float milliVolts0 = myADC.getConversionMillivolts(); // Convert to millivolts.

  Serial.print("ADC voltage Ain0 (mV): ");

  Serial.println(milliVolts0, 6); // Print milliVolts with 6 decimal places

  myADC.setInputMultiplexer(ADS1219_CONFIG_MUX_SINGLE_1); // Read the voltage between AIN1 and GND

  myADC.startSync(); // Start a single-shot conversion.

  while (myADC.dataReady() == false) // Check if the conversion is complete. This will return true if data is ready.
  {
    delay(10); // The conversion is not complete. Wait a little to avoid pounding the I2C bus.
  }

  myADC.readConversion(); // Read the conversion result from the ADC. Store it internally.

  float milliVolts1 = myADC.getConversionMillivolts(); // Convert to millivolts.

  Serial.print("ADC voltage Ain1 (mV): ");

  Serial.println(milliVolts1, 6); // Print milliVolts with 6 decimal places

Thank you “AGAIN” :slight_smile:

Works great!