CircuitsSim.Device.SHT4X (circuits_sim v0.1.2)

View Source

Sensirion SHT4x sensors

Typically found at 0x44 See the datasheet for details.

Call set_humidity_rh/3 and set_temperature_c/3 to change the state of the sensor.

Summary

Types

options()

@type options() :: [{:serial_number, integer()}]

t()

@type t() :: %CircuitsSim.Device.SHT4X{
  acc: binary(),
  broken: nil | {:error, any()},
  crc_injection_count: non_neg_integer(),
  current: atom(),
  humidity_rh: float(),
  serial_number: integer(),
  temperature_c: float()
}

Functions

child_spec(args)

@spec child_spec(keyword()) :: Supervisor.child_spec()

inject_crc_errors(bus_name, address, count)

@spec inject_crc_errors(String.t(), Circuits.I2C.address(), non_neg_integer()) :: :ok

Inject CRC errors into the next n CRC fields

Currently all messages have 2 CRC fields, so this will cause CRC mismatch errors on the next n/2 messages.

new(options \\ [])

@spec new(options()) :: %CircuitsSim.Device.SHT4X{
  acc: binary(),
  broken: term(),
  crc_injection_count: non_neg_integer(),
  current: nil,
  humidity_rh: float(),
  serial_number: integer(),
  temperature_c: float()
}

set_broken(bus_name, address, broken)

@spec set_broken(String.t(), Circuits.I2C.address(), nil | {:error, any()}) :: :ok

Experimental API to return I2C errors on read/read_writes

Set the 3rd argument to an error tuple to be returned or nil to work normally.

set_humidity_rh(bus_name, address, value)

@spec set_humidity_rh(String.t(), Circuits.I2C.address(), number()) :: :ok

set_temperature_c(bus_name, address, value)

@spec set_temperature_c(String.t(), Circuits.I2C.address(), number()) :: :ok