Crates.io | ads1x1x |
lib.rs | ads1x1x |
version | 0.2.2 |
source | src |
created_at | 2018-11-21 09:06:09.663163 |
updated_at | 2021-07-29 21:22:33.146568 |
description | Platform-agnostic Rust driver for the ADS1x1x ultra-small, low-power analog-to-digital converters (ADC). Compatible with the devices: ADS1013, ADS1014, ADS1015, ADS1113, ADS1114 and ADS1115. |
homepage | https://github.com/eldruin/ads1x1x-rs |
repository | https://github.com/eldruin/ads1x1x-rs |
max_upload_size | |
id | 97917 |
size | 100,000 |
This is a platform agnostic Rust driver for the ADS1013, ADS1014, ADS1015,
ADS1113, ADS1114 and ADS1115 ultra-small, low-power
analog-to-digital converters (ADC), based on the embedded-hal
traits.
This driver allows you to:
into_continuous()
.read()
.start()
.read()
.set_data_rate()
.set_full_scale_range()
.is_measurement_in_progress()
.use_alert_rdy_pin_as_ready()
.set_high_threshold_raw()
.set_comparator_mode()
.set_comparator_polarity()
.set_comparator_latching()
.set_comparator_queue()
.disable_comparator()
.The devices are precision, low power, 12/16-bit analog-to-digital converters (ADC) that provide all features necessary to measure the most common sensor signals in an ultra-small package. Depending on the device, these integrate a programmable gain amplifier (PGA), voltage reference, oscillator and high-accuracy temperature sensor.
The devices can perform conversions at data rates up to 3300 samples per second (SPS). The PGA offers input ranges from ±256 mV to ±6.144 V, allowing both large and small signals to be measured with high resolution. An input multiplexer (MUX) allows to measure two differential or four single-ended inputs. The high-accuracy temperature sensor can be used for system-level temperature monitoring or cold-junction compensation for thermocouples.
The devices operate either in continuous-conversion mode, or in a single-shot mode that automatically powers down after a conversion. Single-shot mode significantly reduces current consumption during idle periods. Data is transferred through I2C.
Here is a comparison of the caracteristics of the devices:
Device | Resolution | Sample Rate | Channels | Multi-channel | Features |
---|---|---|---|---|---|
ADS1013 | 12-bit | Max 3300 SPS | 1 | N/A | |
ADS1014 | 12-bit | Max 3300 SPS | 1 | N/A | Comparator, PGA |
ADS1015 | 12-bit | Max 3300 SPS | 4 | Multiplexed | Comparator, PGA |
ADS1113 | 16-bit | Max 860 SPS | 1 | N/A | |
ADS1114 | 16-bit | Max 860 SPS | 1 | N/A | Comparator, PGA |
ADS1115 | 16-bit | Max 860 SPS | 4 | Multiplexed | Comparator, PGA |
Datasheets:
To use this driver, import this crate and an embedded_hal
implementation,
then instantiate the appropriate device.
In the following examples an instance of the device ADS1013 will be created
as an example. Other devices can be created with similar methods like:
Ads1x1x::new_ads1114(...)
.
Please find additional examples using hardware in this repository: driver-examples
use embedded_hal::adc::OneShot;
use linux_embedded_hal::I2cdev;
use nb::block;
use ads1x1x::{channel, Ads1x1x, SlaveAddr};
fn main() {
let dev = I2cdev::new("/dev/i2c-1").unwrap();
let address = SlaveAddr::default();
let mut adc = Ads1x1x::new_ads1013(dev, address);
let value = block!(adc.read(&mut channel::DifferentialA0A1)).unwrap();
println!("Measurement: {}", value);
// get I2C device back
let _dev = adc.destroy_ads1013();
}
For questions, issues, feature requests, and other changes, please file an issue in the github project.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.