EVNDistanceSensor#

This class provides the following features and functionalities for our IR Distance Sensor Standard Peripheral (VL53L0X IC):

  • Time-of-Flight (TOF) Distance Measurements using Infrared Light

    • Since this measures distance by timing pulses of infrared light, readings will be unreliable on transparent objects (e.g. glass)

  • Non-Blocking & Blocking Read Functions

  • Configurable Timing Budget for Readings

  • Built-in I2C Port Selection and De-selection

Note

This class does I2C port selection automatically, so users do not need to call setPort() using their EVNAlpha objects.

Wiring (I2C)#

Host

Peripheral

Description

3V3

VIN

3.3V Power

GND

GND

Ground (0V)

SCL

SCL

I2C Serial Clock

SDA

SDA

I2C Serial Data

Constructor#

class EVNDistanceSensor(uint8_t port, uint8_t timing_budget_ms = 33)#
Parameters
  • port – I2C port the sensor is connected to (1-16)

  • timing_budget_ms – Timing budget allocated for each reading (in ms). Decreasing can lead to lower latency, at the cost of range. Defaults to 33ms

Functions#

bool begin()

Initializes distance sensor. Call this function before using the other functions.

Returns

Boolean indicating whether the sensor was successfully initialized. If false is returned, all other functions will return 0.

void setTimingBudget(uint8_t timing_budget_ms)

Set timing budget for the sensor’s readings. Decreasing can lead to lower latency at the cost of range, & vice versa.

Parameters

timing_budget_ms – Timing budget allocated for each reading (in ms)

uint8_t getTimingBudget()

Get timing budget for the sensor’s readings.

Returns

Timing budget(in ms)

Reading Distance#

uint16_t read(bool blocking = true)

Get distance reading from sensor

Parameters

blocking – Block function from returning a value until a new reading is obtained. Defaults to true

Returns

Distance reading (in mm)

Advanced Sensor Settings#

More info coming soon!

void setSignalRateLimit(float limit)
void setPulsePeriodPreRange(uint8_t period)
void setPulsePeriodFinalRange(uint8_t period)