| Crates.io | variegated-fdc1004 |
| lib.rs | variegated-fdc1004 |
| version | 0.1.0 |
| created_at | 2025-06-05 15:46:38.122458+00 |
| updated_at | 2025-06-05 15:46:38.122458+00 |
| description | Async driver for the Texas Instruments FDC1004 Capacitance-to-Digital Converter |
| homepage | |
| repository | https://github.com/variegated-coffee/variegated-rs |
| max_upload_size | |
| id | 1701724 |
| size | 2,936,962 |
Async driver for the Texas Instruments FDC1004 Capacitance-to-Digital Converter.
The FDC1004 is a precision, 24-bit capacitance-to-digital converter that can measure capacitances from femtofarads to microfarads. It features 4 measurement channels with programmable sample rates and built-in offset compensation.
embedded-hal-asyncdefmt support for logging (behind defmt feature flag)Add this to your Cargo.toml:
[dependencies]
variegated-fdc1004 = "0.1"
# Optional: enable defmt support
variegated-fdc1004 = { version = "0.1", features = ["defmt"] }
use variegated_fdc1004::{FDC1004, Channel, OutputRate, SuccessfulMeasurement};
// Create the driver with your I2C bus and delay provider
let mut fdc = FDC1004::new(i2c_bus, 0x50, OutputRate::SPS100, delay);
// Read capacitance from channel 1 with automatic CAPDAC adjustment
let result = fdc.read_capacitance(Channel::CIN1).await?;
match result {
SuccessfulMeasurement::MeasurementInRange(capacitance) => {
let pf = capacitance.to_pf();
println!("Measured capacitance: {:.2} pF", pf);
},
SuccessfulMeasurement::Overflow => println!("Capacitance too large"),
SuccessfulMeasurement::Underflow => println!("Capacitance too small"),
}
See the datasheet for complete specifications.
This crate can run on any async executor and is no_std compatible.