Can't get any reading from 24-Bit ADS1232 other than 255?

Hey all, I'm fairly new to Arduinos and am trying to wire this 24-bit ADC to a Pro Micro.

I found this library to use but I think I have it wired up incorrectly.

Here's the sketch:

    #include <ADS1232.h>
    
    #include <SPI.h>
    #define SPI_SCK     15
    #define SPI_MISO    14
    
    #define SCALE_CS     7
    #define SCALE_PDWN   2
    #define SCALE_GAIN0  0
    #define SCALE_GAIN1  1
    #define SCALE_SPEED  3
    #define SCALE_A0     4
    #define SCALE_TEMP   5
    
    ADS1232 scale_adc(SCALE_CS, SPI_MISO, SCALE_PDWN, SCALE_GAIN0, SCALE_GAIN1, SCALE_SPEED, SCALE_A0, SCALE_TEMP);
    
    void setup() {
      Serial.begin(9600);
      SPI.begin();
      scale_adc.init(ADS1232::GAIN1, ADS1232::FAST);
    }
    
    void loop() {
      int32_t scaleval;
      scaleval = scale_adc.read();
      Serial.println(scaleval);
    }

The Pro Micro pin out says pin 15 is SPI SLCK and pin 14 is SPI MISO, and those are going to the SCLK and DOUT pins of the ADC respectively. So, I think those are correct. the "SCALE_" pins are all going to the same-named pins on the ADC EXCEPT for SCALE_CS, I'm not sure where that goes and I can't seem to get any different behavior from various pins or unwired.

So, with that out of the way, When I run the sketch all I get is 255. So I'm not sure what exactly is wrong.

Any help is greatly appreciated.

That is so confusing.
The chip is confusing. That library is confusing (far too complicated for a ATmega32U4 chip).
All that is needed is checking if data is ready and then 24 clock pulses.

You can try another library, that is known to work with the ATmega32U4: arduino/libraries/ADS1231 at master · hiveeyes/arduino · GitHub.
Start with the example that comes with that library.
That library is still not easy, it uses direct I/O instructions for faster signals. But you can use any digital pins, and it will still be fast.

this does not look like an SPI device - look under DATA RETRIEVAL in the device datasheet under Technical Documents in

your code has to clock the data in by pulsing a digital pin and reading the corresponing data pin

if you look at the ADS1231.cpp code in library mentioned by @Koepel in post #1 you will how this is done

1 Like

There is a lot of incorrect info going around. You don't need a hardware SPI with MOSI MISO, etc..
Just a few digital pins and it runs fine. But, you need to connect the 3.3V for the digital part AND the 5V for the analog part. The 5V can also be connected to 3.3V. For low noise it is better to have separate power supplies.
I use a modified code I found code for the ADS1244 which has a similar interface and modified it for the ADS1232.

/*
ADS1232, based on a ADS1244 example
Works on an Arduino-pro-mini
It uses software implementation of SPI
*/

int DATA = 3;
int SCLK = 2;

void setup() {
pinMode(DATA, INPUT);
pinMode(SCLK, OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);

digitalWrite(4,HIGH); //scale_PWDN (keep high to stay on)
digitalWrite(5,LOW); //scale Speed (low is slow, high is fast)
digitalWrite(6,HIGH); //scale gain1 (look up in datasheet)
digitalWrite(7,HIGH); //scale gain0
digitalWrite(8,LOW); //scale_temp (high is raw reading of internal temperature sensor, see datasheet)
digitalWrite(9,LOW); //scale_A0 (select channel 1 or 2)

Serial.begin(115200);
Serial.print("ADS1232\n"); //
delay(100);
}
void loop() {
// Code for reading the data:
int32_t value = 0;
digitalWrite(SCLK, HIGH); //enter sleep mode
delay(50);
digitalWrite(SCLK, LOW); // wake up ADC
//delay(5);
//Serial.print("digitalwrite low to sclk to wake up ADC:");
// wait for data ready, stay in while-loop until LOW
while (digitalRead(DATA) == HIGH)
{
//Serial.println("waiting...");
}
value = shiftIn(DATA, SCLK, MSBFIRST);
value <<= 8;
value |= shiftIn(DATA, SCLK, MSBFIRST);
value <<= 8;
value |= shiftIn(DATA, SCLK, MSBFIRST);
digitalWrite(SCLK, HIGH); // enter sleep mode
//digitalWrite(SCLK, LOW); // 25th pulse to keep DATA high till next data ready (default commented)
// process as int24_t (two's compliment 24bit)
value = ((signed long) (value << 8)) >> 8;

Serial.print("value of ADC:");
//Serial.print(value);
Serial.println(value, DEC);
Serial.flush();
}

Hi Bert, please type

[code]

before the first line of your code, and
[/code] after the last line. :slight_smile: