laser_at

Driver for an inexpensive laser rangefinder module, made by Hi-AT, available on aliexpress.

  • Author(s): Phil Underwood

Implementation Notes

Hardware:

Software and Dependencies:

class laser_at.Laser(uart: busio.UART, speed: bytes = b'D')

Driver for low cost laser range finder by Hi-AT.

Parameters:
  • uart (UART) – The I2C bus the LSM6DS3 is connected to.

  • speed – The speed at which to take a measurement. Choices are Laser.FAST, Laser.MEDIUM, and Laser.SLOW

async async_read(timeout=None)

Make an asynchronous laser reading

Parameters:

timeout (int) – How long to wait for a reading in millisecond. Default depends on speed: 1000 for FAST, 3000 for MEDIUM, 6000 for SLOW.

Raises:

LaserError if a bad reading is done, LaserTimeoutError if the reading times out

Returns:

Distance in metres

property distance

Distance as measured by the device

Raises:

LaserError if a bad reading is done, LaserTimeoutError if the reading times out

Returns:

Distance in cm

property on

Whether the laser is currently on or not. You can turn the laser on or off by assigning to this property

read_measurement(timeout: Optional[int] = None) float

Retrieve a reading form the laser

Parameters:

timeout (int) – How long to wait for a reading in millisecond. Default depends on speed: 1000 for FAST, 3000 for MEDIUM, 6000 for SLOW.

Raises:

LaserError if a bad reading is done, LaserTimeoutError if the reading times out

Returns:

Distance in metres

start_measurement()

Start a measurement with the laser

exception laser_at.LaserError

An error while reading from the laser

exception laser_at.LaserTimeoutError

Laser read has timed out