Skip to content

About

Library for UnitDISTANCE using M5UnitUnified.

Topics

Resources

Stars

0 stars

Watchers

4 watching

Forks

Repository files navigation

M5Unit - DISTANCE

Overview

Library for DISTANCE using M5UnitUnified.
M5UnitUnified is a library for unified handling of various M5 units products.

SKU:U098-B1

The Unit Ultrasonic-I2C is an ultrasonic distance measurement sensor with an I2C communication interface. The hardware utilizes the RCWL-9620 ultrasonic distance measurement chip paired with a 16 mm probe, enabling precise distance measurement within a range of 2 cm to 450 cm (with an accuracy of ±2%). As an I2C slave device, the sensor can share bus resources with other I2C devices, maximizing IO resource savings. It is ideal for applications such as robot obstacle avoidance and liquid level detection.

SKU:U098-B2

Unit Ultrasonic-IO is a GPIO interface ultrasonic distance measurement sensor. The hardware uses the RCWL-9620 ultrasonic distance measurement single-chip combined with a 16 mm probe, capable of achieving precise distance measurement within the range of 2 cm-450 cm (accuracy up to ±2%). After the controller sends a trigger signal, the sensor outputs a pulse duration corresponding to the sound wave reflection time, and the distance can be calculated from this data. The IO control method gives this sensor an extremely fast response speed, making it very suitable for applications such as robot obstacle avoidance and liquid level detection.

Future Plans

  • Unit Ultrasonic(SKU:U098) will be supported soon.

Related Link

Required Libraries

License

Examples

See also examples/UnitUnified

For ArduinoIDE settings

You must choose a define symbol for the connection method you will use. (Rewrite source or specify with compile options)

  • PlotToSerial
// *********************************************************************
// Choose connection
// *********************************************************************
#if !defined(CONNECT_VIA_I2C) && !defined(CONNECT_VIA_GPIO)
// For UnitUltraSonicI2C (U098-B1)
// #define CONNECT_VIA_I2C
// For UnitUltraSonicIO (U098-B2)
// #define CONNECT_VIA_GPIO
#endif

For ESP-IDF settings

NOTE: The ESP-IDF native build (idf.py) targets ESP-IDF 5.1 or later (5.x and 6.x).

  • PlotToSerial
    Choose the connection with idf.py menuconfig → M5Unit-DISTANCE PlotToSerial example → Connection (UnitUltraSonicI2C is the default). common/variant.cmake maps the choice to CONNECT_VIA_I2C / CONNECT_VIA_GPIO, so you do not need to edit the source.
cd examples/UnitUnified/UnitUltraSonic/PlotToSerial
idf.py set-target esp32s3               # or esp32 / esp32c5 / esp32c6 / esp32h2 / esp32p4 / ...
idf.py menuconfig
idf.py build flash monitor
  • DualSensor / ViaPaHub
    These examples need no Kconfig choice. Build them directly in the same way.

Support via PaHub

Unit Support Note
UnitUltraSonicI2C OK

Support via PbHub

Unit Support Note
UnitUltraSonicIO NG Echo pulse-width measurement (µs timing) not supported by PbHub

See also the ViaPaHub example and M5Unit-HUB

Doxygen document

GitHub Pages

If you want to generate documents on your local machine, execute the following command

bash docs/doxy.sh

It will output it under docs/html
If you want to output Git commit hashes to html, do it for the git cloned folder.

Required

About

Library for UnitDISTANCE using M5UnitUnified.

Topics

Resources

Stars

0 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages