Struct aht20_driver::AHT20
source · pub struct AHT20<I>{ /* private fields */ }
Expand description
An AHT20 sensor on the I2C bus I
.
The address of the sensor will be SENSOR_ADDRESS
from this package, unless there is some kind
of special address translating hardware in use.
Implementations§
source§impl<E, I> AHT20<I>
impl<E, I> AHT20<I>
sourcepub fn new(i2c: I, address: u8) -> Self
pub fn new(i2c: I, address: u8) -> Self
Initializes the AHT20 driver.
This consumes the I2C bus I
. Before you can get temperature and humidity measurements,
you must call the init
method which calibrates the sensor. The address will almost always
be SENSOR_ADDRESS
from this crate.
sourcepub fn init(
&mut self,
delay: &mut (impl DelayUs<u16> + DelayMs<u16>)
) -> Result<AHT20Initialized<'_, I>, Error<E>>
pub fn init( &mut self, delay: &mut (impl DelayUs<u16> + DelayMs<u16>) ) -> Result<AHT20Initialized<'_, I>, Error<E>>
Run the AHT20 init and calibration routines.
This must be called before any other methods except check_status
. This method will take
at least 40ms to return.
Start (Power on)
│
▼
Wait 40 ms
│
▼
Read status byte ◄─── Wait 10 ms
│ ▲
▼ │
Status::Calibrated ──► No ──► Command::Initialize (0xBE)
│
▼
Yes
Auto Trait Implementations§
impl<I> Freeze for AHT20<I>where
I: Freeze,
impl<I> RefUnwindSafe for AHT20<I>where
I: RefUnwindSafe,
impl<I> Send for AHT20<I>where
I: Send,
impl<I> Sync for AHT20<I>where
I: Sync,
impl<I> Unpin for AHT20<I>where
I: Unpin,
impl<I> UnwindSafe for AHT20<I>where
I: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more