| Crates.io | variegated-nau7802 |
| lib.rs | variegated-nau7802 |
| version | 0.2.0 |
| created_at | 2025-06-05 15:48:16.314742+00 |
| updated_at | 2025-06-05 16:38:53.832764+00 |
| description | Async driver for the Nuvoton NAU7802 24-bit precision ADC for load cells |
| homepage | |
| repository | https://github.com/variegated-coffee/variegated-rs |
| max_upload_size | |
| id | 1701727 |
| size | 942,859 |
Async driver for the Nuvoton NAU7802 24-bit precision ADC for load cells and bridge sensors.
The NAU7802 is a precision, 24-bit analog-to-digital converter designed specifically for bridge sensor applications like load cells and strain gauges. It features a programmable gain amplifier, on-chip voltage reference, and calibration capabilities optimized for weight measurement systems.
embedded-hal-asyncAdd this to your Cargo.toml:
[dependencies]
variegated-nau7802 = "0.1"
use variegated_nau7802::{Nau7802, Nau7802DataAvailableStrategy, Gain, SamplesPerSecond, Ldo};
// Create the driver with I2C bus and delay provider
let data_strategy = Nau7802DataAvailableStrategy::Polling;
let mut nau = Nau7802::new(i2c, data_strategy, delay, Some(0x2A)); // Default I2C address
// Initialize the device with high-level init function
nau.init(Ldo::L3v3, Gain::G128, SamplesPerSecond::SPS80).await?;
// Read weight measurement
loop {
// Wait for data to be available
nau.wait_for_data_available().await?;
// Read the measurement
let reading = nau.read().await?;
println!("ADC reading: {}", reading);
// Convert to weight using your calibration factor
let weight_grams = (reading as f32) * calibration_factor;
println!("Weight: {:.1} g", weight_grams);
delay.delay_ms(100).await;
}
The NAU7802 supports analog front-end calibration:
use variegated_nau7802::{Nau7802, Nau7802DataAvailableStrategy, AfeCalibrationStatus};
// Start AFE calibration (built into the init function)
nau.begin_afe_calibration().await?;
// Check calibration status
let cal_status = nau.poll_afe_calibration_status().await?;
match cal_status {
AfeCalibrationStatus::Success => println!("Calibration successful"),
AfeCalibrationStatus::InProgress => println!("Calibration in progress..."),
AfeCalibrationStatus::Failure => println!("Calibration failed"),
}
// Power up the device (included in init function)
nau.power_up().await?;
// Reset to default state
nau.start_reset().await?;
nau.finish_reset().await?;
Based on amiraeva/nau7802-rs. See the datasheet for complete specifications.
This crate can run on any async executor and is no_std compatible.