0
\$\begingroup\$

I have the ADS1113 ADC connected to the Arduino using the I2C protocol. I'm just trying to read the analog data from the ADC. I have 5 volts connected to the AIN0 and AIN1 inputs. When I check the Wire.endTransmission() value I keep getting a zero back, meaning the data was successfully transmitted. Yet, when requesting 4 bytes I keep getting this, even if I change the voltage at the AIN0 and AIN1 inputs.

enter image description here

I pretty new to using I2C and learning how to setup particular ICs from reading the data sheet: http://www.ti.com/lit/ds/sbas444c/sbas444c.pdf The QuickStart Guide is on page 33 (Sorry I tried posting a pic of what it says, but I don't have high enough reputation to post more than two links...).

So I guess my question is, how do I obtain the second and third byte values? Or am I completely off and not even supposed to be reading the data from the conversion register?

#include <Wire.h>


void setup()
{
  Serial.begin(9600); 
  Wire.begin(); 

}

void loop()
{
  int sensorValue = analogRead(A0);             //compare to ADC data
  float voltage = sensorValue * (5.0 / 1023.0);
  Serial.println(voltage);
  Serial.println();

  Wire.beginTransmission(B1001000);         //Address of ADC
  Wire.write(1);                          
  int ack = Wire.endTransmission();       
  Serial.print("I2C = ");
  Serial.print(ack);                      
  Serial.println();
  delay(15); 

  Wire.requestFrom(B1001000,4,1); //Requesting 4 bytes 
  while(Wire.available()){
    float RAW = Wire.read();
    float RAW_voltage = (RAW*4.096/32768.0);
    Serial.print("Raw ADC value = ");
    Serial.print(RAW);
    Serial.print("\tVoltage = ");
    Serial.print(RAW_voltage);
    Serial.println();
  }
  delay(1000); 

}
\$\endgroup\$
0
\$\begingroup\$

What do you mean about 4bytes. Your code is correct and received all requested 4 bytes 1 by 1

this loop run four times and received all data from the I2c Slave.

 while(Wire.available()){    



    float RAW = Wire.read();  <<--------------- at this line 
    float RAW_voltage = (RAW*4.096/32768.0);
    Serial.print("Raw ADC value = ");
    Serial.print(RAW);
    Serial.print("\tVoltage = ");
    Serial.print(RAW_voltage);
    Serial.println();
  }

But if your ADC values are not changed that means your sensor ADS1113 not configure/working correctly first of all check your sensor output.

\$\endgroup\$
  • \$\begingroup\$ I thought maybe I was requesting 4 bytes of information from the ADC. Ahhh ok, thanks. What do you mean by checking the sensor output though? \$\endgroup\$ – Zach Stow Oct 23 '17 at 7:22
  • \$\begingroup\$ Ohh, i think you are using an external sensor or somthing like voltage source \$\endgroup\$ – Bhura Oct 23 '17 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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