An Arduino library for ESP32 development board that can measure distance from an analog Sharp IR sensor.
Currently supports:
- GP2Y0A21YK0F
Usage
- Adding the library to the sketch
#include <ESP32SharpIR.h>
- Creating an instance
SharpIR sensorName(sensorModel, sensorPin);
sensorName : the name of the object
sensorModel : the model code of the sensor (e.g. GP2YA41SK0F)
sensorPin : the analog pin where the sensor Vout pin is attached
- Acquiring data
sensorName.getDistance();
sensorName.getDistance( avoidBurstRead );
sensorName.getRawDistance();
sensorName.getRawDistance( avoidBurstRead );
avoidBurstRead : can be true or false
- Apply a filter
sensorName.setFilterRate(float rate);
rate : a value from the range from 0.01 to 0.99. 0.01 equal to sampling 100 values and getting the average.
Resources / Links
Tags
ESP32
PlatformIO
Firmware
Library