I have an ADS1113 ADC connected to an 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 0 back, meaning the data was successfully transmitted.
Yet, when requesting 4 bytes I keep getting this, even when I change the voltage at the AIN0 and AIN1 inputs:
I am pretty new to using I2C and learning how to setup particular ICs from reading the data sheet. The QuickStart Guide is on page 35 (I tried posting a pic of what it says, but I don't have high enough reputation to post more than two links).
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);
}