microrobotics icon

ADS1110 Changin MUX mode

microrobotics | PRO | 05/06/23 04:26:07 PM UTC | 0 ⭐ | 2834 👁️ | Never ⏰ | [Arduino, ADS1110, MUX]
Arduino |

1.16 KB

|

None

|

0 👍

/

0 👎

#include <Wire.h>
 
const int ADS1110_ADDRESS = 0x48; // I2C address of the ADS1110
 
void setup() {
  Wire.begin();
  Serial.begin(9600);
  
  // Configure the ADS1110
  Wire.beginTransmission(ADS1110_ADDRESS);
  Wire.write(0x85); // Config register address
  Wire.write(0x83); // Single-ended measurement on AIN0, gain = 2/3, mode = continuous conversion, data rate = 860 SPS
  Wire.endTransmission();
}
 
void loop() {
  // Start a conversion
  Wire.beginTransmission(ADS1110_ADDRESS);
  Wire.write(0x80); // Conversion register address
  Wire.endTransmission();
  
  // Wait for the conversion to finish (13 ms for 860 SPS)
  delay(15);
  
  // Read the conversion result (MSB first)
  Wire.requestFrom(ADS1110_ADDRESS, 2);
  byte msb = Wire.read();
  byte lsb = Wire.read();
  int result = (msb << 8) | lsb;
  
  // Print the result
  Serial.print("AIN0 voltage: ");
  float voltage = result * 0.1875 / 1000; // Calculate voltage (16-bit result * LSB value * Vref / gain / 1000)
  Serial.print(voltage, 4); // Print voltage with 4 decimal places
  Serial.println(" V");
  
  delay(1000); // Wait for 1 second before taking the next measurement
}

Comments