4 个版本
0.1.4 | 2023 年 6 月 24 日 |
---|---|
0.1.3 | 2023 年 6 月 24 日 |
0.1.2 | 2023 年 6 月 23 日 |
0.1.0 | 2023 年 6 月 23 日 |
#27 in #esp
16KB
soil_moisture1.2c6
用于 esp32 系列的土壤湿度库,目前只在 esp32 c6 上测试。如果您成功使其在您的 esp32 上运行,请提交一个 commit 或发消息给我,我会将其添加到测试的 esp32 中。请注意,这些值是我自己的传感器(干、湿)读数,您可以提交您的或自行修改,我可能会稍后添加对自定义的支持。例如用法
use esp_idf_sys as _; // If using the `binstart` feature of `esp-idf-sys`, always keep this module imported
use esp_idf_hal::{adc::{AdcDriver, config::Config, Atten11dB, AdcChannelDriver}, prelude::Peripherals, gpio::{Gpio5}, delay::Delay, };
use log::*;
use soil_moisture_hal::SoilMoisture;
fn main() {
// It is necessary to call this function once. Otherwise some patches to the runtime
// implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
esp_idf_sys::link_patches();
// Bind the log crate to the ESP Logging facilities
esp_idf_svc::log::EspLogger::initialize_default();
info!("program starts");
let peripherals = Peripherals::take().unwrap();
let mut soil_moisture = SoilMoisture::new(peripherals.adc1, peripherals.pins.gpio5).unwrap();
//let mut adc = AdcDriver::new(peripherals.adc1, &Config::new().calibration(true)).unwrap();
/*let mut adc_pin: esp_idf_hal::adc::AdcChannelDriver<'_, Gpio5, Atten11dB<_>> =
AdcChannelDriver::new(peripherals.pins.gpio5).unwrap();*/
//let x = MyStruct::new(adc);
loop
{
//println!("ADC value: {}", adc.read(&mut adc_pin).unwrap());
println!("Moisture level: {}", soil_moisture.get_moisture_precentage().unwrap());
Delay::delay_ms(1000);
}
}
依赖项
~2–12MB
~144K SLoC