Skip to main content

AS3935

Struct AS3935 

Source
pub struct AS3935<I2C, D> { /* private fields */ }
Expand description

the AS3935 device

Implementations§

Source§

impl<I2C, D, E> AS3935<I2C, D>
where I2C: I2c<Error = E>, D: DelayNs,

Source

pub fn new(i2c: I2C, address: u8, delayer: D) -> Self

create new AS3935 driver with address and delay given the datasheet states the max speed is 400 kHz with just AS3935 on the bus and external 10 k pull ups otherwise use 4k7 pulls up and max speed is 100 kHz.
Best to use 100 kHz. use constant::DeviceAddress::default() with AD1 and AD0 pins high

Source

pub fn release(self) -> I2C

give back the I2C interface

Source§

impl<I2C, D, E> AS3935<I2C, D>
where I2C: I2c<Error = E>, D: DelayNs,

Source

pub fn calibrate_osc(&mut self) -> Result<(), Error<E>>

calibrate both internal oscillators, first tune your antenna

Source

pub fn reset_settings(&mut self) -> Result<(), Error<E>>

reset all settings to defaults

Source

pub fn get_lightning_energy(&mut self) -> Result<u32, Error<E>>

read lightning energy (unit-less as per datasheet)

Source

pub fn display_oscillator( &mut self, state: bool, osc: Oscillator, ) -> Result<(), Error<E>>

display oscillator on IRQ pin state = true to turn on, false to turn off use a logic analyzer or oscilloscope to see the clock signal.

Source

pub fn get_distance_to_storm(&mut self) -> Result<StormFrontDistance, Error<E>>

get distance to storm front in km. > 40 km == OutOfRange

Source

pub fn power_down(&mut self) -> Result<(), Error<E>>

power_down note: the TRCO oscillator must then be recalibrated after power_down() call which is built into wakeup()

Source

pub fn set_indoor_outdoor(&mut self, location: Location) -> Result<(), Error<E>>

set indoor-outdoor location of sensor

Source

pub fn get_indoor_outdoor(&mut self) -> Result<Location, Error<E>>

get indoor-outdoor location from sensor

Source

pub fn get_interrupt_register(&mut self) -> Result<INTType, Error<E>>

get interrupt register: useful to see what the AS3935 detected

Source

pub fn wakeup(&mut self) -> Result<(), Error<E>>

wakup, and then calibrate the oscillators

Source

pub fn set_watchdog_threshold(&mut self, threshold: u8) -> Result<(), Error<E>>

set watchdog threshold, threshold < 11

Source

pub fn get_watchdog_threshold(&mut self) -> Result<u8, Error<E>>

get watchdog threshold

Source

pub fn set_noise_level(&mut self, level: u8) -> Result<(), Error<E>>

set noise floor level, level < 8

Source

pub fn get_noise_level(&mut self) -> Result<u8, Error<E>>

get noise floor level

Source

pub fn set_lightning_threshold( &mut self, threshold: MinStrikes, ) -> Result<(), Error<E>>

set lightning threshold (minimum number of lightning strikes)

Source

pub fn get_lightning_threshold(&mut self) -> Result<MinStrikes, Error<E>>

get lightning threshold (minimum number of lightning strikes)

Source

pub fn clear_statistics(&mut self) -> Result<(), Error<E>>

clear statistics : clears the number of lightning strikes detected in last 15 minutes

Source

pub fn set_mask_disturber(&mut self, enable: bool) -> Result<(), Error<E>>

set mask disturber: defines if “disturbers” trigger interrupts, default is false == not masked

Source

pub fn get_mask_disturber(&mut self) -> Result<bool, Error<E>>

get mask disturber: whether disturbers triggers interrupts

Source

pub fn set_spike_rejection(&mut self, sensitivity: u8) -> Result<(), Error<E>>

set spike rejection sensitivity < 16

Source

pub fn get_spike_rejection(&mut self) -> Result<u8, Error<E>>

get spike rejection sensitivity

Source

pub fn set_antenna_div_ratio(&mut self, ratio: u8) -> Result<(), Error<E>>

set antenna frequency division ratio for antenna tuning ratios are: 16, 32, 64 or 128

Source

pub fn get_antenna_div_ratio(&mut self) -> Result<u8, Error<E>>

get antenna frequency division ratio for antenna tuning

Source

pub fn set_tuning_cap(&mut self, p_farads: u8) -> Result<(), Error<E>>

set tuning cap for antenna farads must be <= 128 and modulo 8, specifically from 0 to 120 pF in steps of 8 pF (modulo 8)

Source

pub fn get_tuning_cap(&mut self) -> Result<u8, Error<E>>

get tuning cap (internal) for antenna in pF, manufacturer default is 0 pF if not changed

Auto Trait Implementations§

§

impl<I2C, D> Freeze for AS3935<I2C, D>
where I2C: Freeze, D: Freeze,

§

impl<I2C, D> RefUnwindSafe for AS3935<I2C, D>

§

impl<I2C, D> Send for AS3935<I2C, D>
where I2C: Send, D: Send,

§

impl<I2C, D> Sync for AS3935<I2C, D>
where I2C: Sync, D: Sync,

§

impl<I2C, D> Unpin for AS3935<I2C, D>
where I2C: Unpin, D: Unpin,

§

impl<I2C, D> UnsafeUnpin for AS3935<I2C, D>
where I2C: UnsafeUnpin, D: UnsafeUnpin,

§

impl<I2C, D> UnwindSafe for AS3935<I2C, D>
where I2C: UnwindSafe, D: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.