sysfs_hcsr04 is a Viam modular sensor component that provides distance readings from the HCSR04 ultrasonic sensor for boards that can use sysfs to interact with GPIO.
sudo apt update && sudo apt upgrade -y
sudo apt-get install python3
sudo apt install python3-pip
The sysfs_hcsr04 resource fulfills the Viam sensor interface
The get_readings() command takes no arguments, and returns the detected distance in meters (with the key 'distance').
This component should be configured as type sensor, model viamlabs:sensor:sysfs-hcsr04.
The following attributes may be configured as sysfs_hcsr04 component config attributes.
Example:
{
"trigger_pin": 32,
"echo_pin": 30
}
integer - required
integer - required