Skip to content

elixir-sensors/veml7700

Repository files navigation

VEML7700

Hex version CI

Use Vishay ambient light sensor VEML7700 in Elixir.

Usage

Here's an example use. VEML7700 sensors are at address 0x10; VEML6030 typically at 0x48.

Run in Livebook

iex> {:ok, veml} = VEML7700.start_link(bus_name: "i2c-1", bus_address: 0x10)
{:ok, #PID<0.2190.0>}

iex> VEML7700.get_als_config(veml)
{:ok,
 {[:als_gain_1_4,
   :als_100ms,
   :als_persistence_1,
   :als_interrupt_disable,
   :als_shutdown], 0.2304}}

iex> VEML7700.set_als_config(veml, [:als_gain_1, :als_200ms, :als_power_on])
{:ok,
 {[:als_gain_1,
   :als_200ms,
   :als_persistence_1,
   :als_interrupt_disable,
   :als_power_on], 0.0288}}

iex> VEML7700.measure(veml)
{:ok,
  %VEML7700.Measurement{
    light_lux: 9.9072,
    timestamp_ms: 284622415448}}}}

For details, see API reference.