Reference

Library

Communication Protocol Description

  • Supported Platforms: Ready to use out of the box, compatible with Arduino, micro:bit, and ESP32.
  • Programming Methods: Comprehensive libraries and tutorials are available whether you use the Arduino IDE or graphical programming tools like Mind+ and MakeCode.
  • Connection Methods: Supports Gravity-I2C interface, UART connection, or direct connection to a computer via USB-C.
  • Cascading Support: Provides 4 switchable I2C addresses, allowing cascading of up to 4 sensors to expand the field of view.
  • UART Baud Rate: 115200bps (fixed, non-modifiable)

API Description

/**
 * @fn begin
 * @brief Initializes the sensor
 * @return NULL
 */
uint8_t begin(void);

/**
 * @fn setRangingMode
 * @brief Configures the retrieval of all data
 * @param matrix Configuration matrix for sensor sampling
 * @return Returns the configuration status
 * @retval 0 Success
 * @retval 1 Failure
 */
uint8_t setRangingMode(eMatrix_t matrix);


/**
 * @fn getAllData
 * @brief Retrieves all data
 * @param buf Buffer to store the data
 */
uint8_t getAllData(void *buf);

/**
 * @fn getFixedPointData
 * @brief Retrieves data for a specific point
 * @param x X coordinate
 * @param y Y coordinate
 * @return Returns the retrieved data
 */
uint16_t getFixedPointData(uint8_t x, uint8_t y);

MakeCode Block Module Description

The functions after loading the library via the extension feature are shown in the figure below:

In MakeCode, there are two modes: Matrix Mode and Obstacle Avoidance Mode.

  • Matrix Mode: By selecting different I2C addresses, it supports cascading up to 4 sensors for simultaneous use.
  • Obstacle Avoidance Mode: This is a test function intended solely for testing purposes. It may contain bugs or have limitations in user experience.

Other Supplementary Information

Was this article helpful?

TOP