ultrasonic - Driver for ultrasonic range meters HC-SR04, HY-SRF05

group ultrasonic

ESP-IDF driver for ultrasonic range meters, e.g.

HC-SR04, HY-SRF05 and so on

Ported from esp-open-rtos

Copyright (C) 2016, 2018 Ruslan V. Uss unclerus@gmail.com

BSD Licensed as described in the file LICENSE

Defines

ESP_ERR_ULTRASONIC_PING
ESP_ERR_ULTRASONIC_PING_TIMEOUT
ESP_ERR_ULTRASONIC_ECHO_TIMEOUT

Functions

esp_err_t ultrasonic_init(const ultrasonic_sensor_t *dev)

Init ranging module.

Return

ESP_OK on success

Parameters
  • dev: Pointer to the device descriptor

esp_err_t ultrasonic_measure_cm(const ultrasonic_sensor_t *dev, uint32_t max_distance, uint32_t *distance)

Measure distance.

Return

ESP_OK on success

Parameters
  • dev: Pointer to the device descriptor

  • max_distance: Maximal distance to measure, centimeters

  • distance: Distance in centimeters or ULTRASONIC_ERROR_xxx if error occurred

struct ultrasonic_sensor_t
#include <ultrasonic.h>

Device descriptor.