variegated-fdc1004
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.
Features
- Async/await support using
embedded-hal-async - Support for all 4 measurement channels
- Configurable sample rates (100, 200, 400 SPS)
- Automatic CAPDAC offset compensation
- Single-ended and differential measurements
- Optional
defmtsupport for logging (behinddefmtfeature flag)
Usage
Add this to your Cargo.toml:
[]
= "0.1"
# Optional: enable defmt support
= { = "0.1", = ["defmt"] }
Example
use ;
// Create the driver with your I2C bus and delay provider
let mut fdc = FDC1004new;
// Read capacitance from channel 1 with automatic CAPDAC adjustment
let result = fdc.read_capacitance.await?;
match result
Hardware Considerations
- Operating voltage: 2.7V to 5.5V
- I2C address: 0x50 (7-bit)
- Requires external 18pF reference capacitors on CAPDAC pins
- Sample rate affects both speed and accuracy
See the datasheet for complete specifications.
Interoperability
This crate can run on any async executor and is no_std compatible.