Crates.io | pt-rtd |
lib.rs | pt-rtd |
version | 0.1.1 |
source | src |
created_at | 2023-02-19 19:50:04.93885 |
updated_at | 2023-02-19 20:18:32.070129 |
description | Calculation of resistance and temperature for platinum type RTDs, e.g. PT100. |
homepage | |
repository | https://github.com/thecodechemist99/pt-rtd |
max_upload_size | |
id | 789243 |
size | 20,155 |
Add this to your Cargo.toml
:
[dependencies]
pt-rtd = "0.1"
Conversion of temperature and resistance values:
use pt_rtd::{
self as rtd,
RTDType,
};
fn main() -> ! {
let resistance: f32 = 100.0;
let temperature: f32 = 0.0;
// Convert resistance to temperature
let result = rtd::calc_t(resistance, RTDType::PT100);
let t = match result {
Ok(temp) => temp,
Err(e) => // handle error
}
// Convert temperature to resistance
let result = rtd::calc_r(temperature, RTDType::PT100);
let r = match result {
Ok(res) => res,
Err(e) => // handle error
}
}
For relative mesurements, the library can also convert the ADC reading to a resistance value:
use pt_rtd::{
self as rtd,
ADCRes,
};
fn main() -> ! {
let adc_value: u32 = 1000;
let adc_resolution = ADCRes::B24;
let ref_resistance = 5600;
let pga_gain = 16;
let result = rtd::conv_d_val_to_r(adc_value, ref_resistance, adc_resolution, pga_gain);
let r = match result {
Ok(res) => res,
Err(e) => // handle error
}
}