DYP-A01
Use DYP-A01 ultrasonic distance sensor in Elixir.
Usage
# List available serial ports
iex> Circuits.UART.enumerate
%{
"ttyAMA0" => %{},
"ttyS0" => %{},
"ttyUSB0" => %{
description: "CP2102 USB to UART Bridge Controller",
manufacturer: "Silicon Labs",
product_id: 60000,
serial_number: "0001",
vendor_id: 4292
}
}
# Start a gen server for interacting with a DYP-A01 sensor on port ttyAMA0
iex> {:ok, pid} = DYPA01.start_link(port_name: "ttyAMA0")
{:ok, #PID<0.1407.0>}
# Measure the current distance
iex> DYPA01.measure(pid)
{:ok, %DYPA01.Measurement{distance_mm: 1680, timestamp_ms: 321793}}