I am trying to read data from an ADC ADCS7476 (datasheet) using SPI on Arduino Uno. I am using the following code to read the data from the ADC and printing it on serial monitor. However, the code is always printing 0. I never used SPI before and I am not able to debug the issue, does anyone know where I am going wrong.

I am using the following connections:

  1. ADC's SCLK to Pin 13 on Ardunio
  2. ADC's SDATA to Pin 12 on Arduino
  3. ADC's CS to Pin 10 on Arduino


#include <SPI.h>
#define cs 10

SPISettings settingsA(250000, MSBFIRST, SPI_MODE0);
byte highbyte,lowbyte;
unsigned int data;

void setup() {
  pinMode(cs, OUTPUT);
  digitalWrite(cs, HIGH); 

void loop() {
  digitalWrite(cs, LOW);
  highbyte = SPI.transfer(0xFF);
  lowbyte = SPI.transfer(0xFF);
  digitalWrite(cs, HIGH);
  data= ((unsigned int)highbyte << 8 ) + lowbyte;
  • 1
    apart from the #include and #define having a space (but since the compiler does not complain I think it is just a wrong copy-paste), I can't see anything obviously wrong. So, just for the most basic questions, 1) is the circuit powered? 2) does the ADC have its own power supply or you are powering it from the arduino 5V? 3) if the former, did you connect th two grounds? 4) is the adc powered at 5V? 5) Can you attach an oscilloscope to the data and clock lines to see what is on the bus?
    – frarugi87
    Nov 30, 2018 at 14:04
  • see the BarometricPressureSensor example of the SPI library
    – Juraj
    Nov 30, 2018 at 14:09
  • You can't delay this little delayMicroseconds(1); Minimum workable value is 3 or 4 per the Arduino Reference section.
    – CrossRoads
    Nov 30, 2018 at 19:03
  • You also don't need this line at all SPISettings settingsA(250000, MSBFIRST, SPI_MODE0); The default settings use 4 MHz, clock, MSBFIRST, SPI Mode 0. The part works with up to 20 MHz clock, so 4 would be fine. At 16 MHz, 1 uS is 16 clocks, so digitalWrite or two to another pin after taking CS low would give a short delay for the conversion to get started.
    – CrossRoads
    Nov 30, 2018 at 19:15
  • @frarugi87 The circuit is powered from the arduino 5v and the two grounds are connected. I will attach the oscilloscope screenshots by tonight or tomorrow.
    – rithvikp
    Dec 1, 2018 at 4:30

1 Answer 1


I am leaving this answer in case anyone stumbles across this question in the future

In a super frustrating, anti-climactic end, it turns out that the ADC chip itself was not working properly. I tested the (faulty) chip using the code above and observed the output of data pin on the oscilloscope and the output was the same square wave irrespective of the input. I managed to find a new ADC and I tested it and it was working correctly. But this raises a new issue for me, this is the third ADC chip I tested that was working correctly, the first two were faulty. It is very unlikely that it is a manufacturing issue and I used the same connections and the same code to test all three of them. Maybe it has to something to do with soldering, because AFAIK that's the only thing that's different. If anyone knows anything else that might have gone wrong, I'm all ears.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.