Circuits.I2C.detect_devices
detect_devices
, go back to Circuits.I2C module for more information.
Convenience method to scan all I2C buses for devices
This is only intended to be called from the IEx prompt. Programs should
use detect_devices/1
.
Specs
Scan the I2C bus for devices by performing a read at each device address and returning a list of device addresses that respond.
WARNING: This is intended to be a debugging aid. Reading bytes from devices can advance internal state machines and might cause them to get out of sync with other code.
iex> Circuits.I2C.detect_devices("i2c-1")
[4]
The return value is a list of device addresses that were detected on the
specified I2C bus. If you get back 'Hh'
or other letters, then IEx
converted the list to an Erlang string. Run i v()
to get information about
the return value and look at the raw string representation for addresses.
If you already have a reference to an open device, then you may pass its
reference
to detect_devices/1
instead.