BB.Message.Sensor.PowerState (bb v0.19.0)

Copy Markdown View Source

Instantaneous electrical state of a measured circuit, bus, or device.

Published by power-monitor chips (e.g. INA219, INA226) and any device that exposes voltage and current as part of its normal telemetry (e.g. Robotis or Feetech servos reporting their own draw).

This is a raw electrical snapshot. Battery-aware concepts like state-of-charge, percentage, or health belong in BB.Message.Sensor.BatteryState and are the job of a downstream consumer that subscribes to PowerState and maintains charge state.

Fields

  • voltage - Bus voltage in Volts
  • current - Current in Amperes (signed; sign convention is producer-defined, typically positive = flowing in the measured direction)
  • power - Power in Watts, or nil if the producer doesn't measure it
  • shunt_voltage - Shunt voltage in Volts, or nil if not exposed (diagnostic)

Examples

alias BB.Message.Sensor.PowerState

{:ok, msg} = PowerState.new(:battery_bus,
  voltage: 12.4,
  current: 0.85,
  power: 10.54
)

Summary

Types

t()

@type t() :: %BB.Message.Sensor.PowerState{
  current: float(),
  power: float() | nil,
  shunt_voltage: float() | nil,
  voltage: float()
}

Functions

new(frame_id, attrs)

@spec new(
  atom(),
  keyword()
) :: {:ok, BB.Message.t()} | {:error, term()}