I am not working with the ADS1118, but with the ADS1293 and I am also using SPI.
Are you sure about SPI mode being SPI_MODE1?
What is happening, is that your output is always 2^15 (=32'768).
So basically it returns 0 all the time, except for the first bit, which is 1.
In my system, I got it to work, by adding SPI.startTransaction() and SPI.endTransaction()
#define BitOrder MSBFIRST
#define SPIMode SPI_MODE0
uint8_t chipSelectPin = 6;
uint32_t UpperByte = 0;
uint16_t LowerBytes = 0;
// the 0x80 tells the sensor that I want to read (not write), then the 0x50 is the address in the sensor memory
uint8_t readAddress = (0x80 | 0x50);
// Begin Transaction and Select Sensor
SPI.beginTransaction(SPISettings(20000000, BitOrder, SPIMode));
// Tell Sensor where to READ information from
// Read information for 3 Bytes
// THIS IS A 24bit VALUE
UpperByte = SPI.transfer(0x00);
LowerBytes = ( (uint16_t) SPI.transfer(0x00) << 8) | (uint8_t) SPI.transfer(0x00);
// Deselect Sensor and End Transaction
- Why are you delaying it by 1000ns or 1microsecond? Follow precisely whatever is explained in the datasheet.
- In such applications, where the actual size of your data is quite relevant, I would suggest to TELL specify what data size to use (int16_t or similar, instead of int/byte/char etc.), as this could work differently on another system!
- This could maybe explain an error you are getting from bit-shifting your MSB before saving it to rawValue.