mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-08 05:27:09 +00:00
21 lines
569 B
C
21 lines
569 B
C
#ifndef __ULTRASONIC_H__
|
|
#define __ULTRASONIC_H__
|
|
|
|
#include "driver/gpio.h"
|
|
#include "esp_err.h"
|
|
|
|
#define TRIGGER_LOW_DELAY 4
|
|
#define TRIGGER_HIGH_DELAY 10
|
|
#define PING_TIMEOUT 6000
|
|
#define ROUNDTRIP_M 5800.0f
|
|
#define ROUNDTRIP_CM 58
|
|
|
|
typedef struct {
|
|
gpio_num_t trigger_gpio; // GPIO for the trigger pin
|
|
gpio_num_t echo_gpio; // GPIO for the echo pin
|
|
} ultrasonic_sensor_t;
|
|
|
|
esp_err_t ultrasonic_init (const ultrasonic_sensor_t *sensor);
|
|
esp_err_t ultrasonic_measure_raw (const ultrasonic_sensor_t *sensor,uint32_t max_time_us, uint32_t *time_us);
|
|
|
|
#endif |