Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Here is an example code for the ADS1110 High Precision A/D Converter, 16-Bit, I2C, Low Power:
- This code reads the voltage on a single-ended AIN0 input of the ADS1110 High Precision A/D Converter, 16-Bit, I2C, Low Power and prints the conversion result on the Serial Monitor of the Arduino IDE. The ADS1110 is configured for 16-bit resolution and 64 samples per second (SPS) using the configuration register. The conversion result is read from the conversion register and converted to a voltage using the formula (raw_value / 32767.0) * 2.048.
- To use this code, connect the AIN0 input of the ADS1110 to a voltage source within the specified range of the ADS1110. Connect the SDA and SCL pins of the ADS1110 to the corresponding pins of the Arduino board (usually A4 and A5 for most Arduino boards). The ADS1110 should be powered with a 2.7-5.5V DC power source.
- Note that this code only reads the voltage on a single-ended AIN0 input of the ADS1110. You can modify the code to read the voltage on other input channels or to use differential inputs. Also, note that the conversion speed and accuracy of the ADS1110 can be affected by various factors, such as the power supply voltage, the input voltage range, and the noise level of the system.
- */
- #include <Wire.h>
- #define ADS1110_ADDR 0x48
- void setup() {
- Serial.begin(9600);
- Wire.begin();
- }
- void loop() {
- // Start conversion
- Wire.beginTransmission(ADS1110_ADDR);
- Wire.write(0x01); // Address pointer to configuration register
- Wire.write(0x84); // Single-ended AIN0, 16-bit resolution, 64 SPS
- Wire.endTransmission();
- // Wait for conversion to complete
- delay(20); // 1/SPS + 1 ms margin
- // Read conversion result
- Wire.beginTransmission(ADS1110_ADDR);
- Wire.write(0x00); // Address pointer to conversion register
- Wire.endTransmission();
- Wire.requestFrom(ADS1110_ADDR, 2);
- int16_t raw_value = (Wire.read() << 8) | Wire.read();
- float voltage = (raw_value / 32767.0) * 2.048;
- // Print result
- Serial.print("Raw value: ");
- Serial.print(raw_value);
- Serial.print(", Voltage: ");
- Serial.println(voltage);
- // Wait for 1 second before taking the next reading
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement