This module implements the "rdk:component:sensor"
API and "rdk:component:camera"
API to integrate the HC-S204 ultrasonic distance sensor into your machine.
Two models are provided:
viam:ultrasonic:sensor
- Configure as a sensor to access the sensor method GetReadings().viam:ultrasonic:camera
- When configured as a camera, you can use the camera method GetPointCloud(), rather than GetReadings().
Navigate to the CONFIGURE tab of your machine's page in the Viam app, searching for ultrasonic
and selecting one of the above models.
You must have a board component configured to use an ultrasonic sensor or an ultrasonic camera. The ultrasonic sensor or camera uses the board component to access and use the pins on the board.
Fill in the attributes as applicable to your sensor, according to the example below.
{
"trigger_pin": "<pin-number>",
"echo_interrupt_pin": "<pin-number>",
"board": "<your-board-name>",
"timeout_ms": <int>
}
Attribute | Type | Required? | Description |
---|---|---|---|
trigger_pin |
string | Required | The physical pin number of the board's GPIO pin that you have wired the ultrasonic's trigger pin to. |
echo_interrupt_pin |
string | Required | The physical pin number of the pin the ultrasonic's echo pin is wired to on the board. If you have already created a digital interrupt for this pin in the board's configuration, use that digital interrupt's name instead. |
board |
string | Required | The name of the board the ultrasonic is wired to. You must have a board component configured to make use of the board's pins. |
timeout_ms |
int | Optional | Time to wait in milliseconds before timing out of requesting to get ultrasonic distance readings. Default: 1000 . |
Similarly for the ultrasonic camera:
{
"trigger_pin": "<pin-number>",
"echo_interrupt_pin": "<pin-number>",
"board": "<your-board-name>",
"timeout_ms": <int>
}
The following attributes are available for the ultrasonic
cameras:
Attribute | Type | Required? | Description |
---|---|---|---|
trigger_pin |
string | Required | The physical pin number of the board's GPIO pin that you have wired the ultrasonic's trigger pin to. |
echo_interrupt_pin |
string | Required | The physical pin number of the pin the ultrasonic's echo pin is wired to on the board. If you have already created a digital interrupt for this pin in the board's configuration, use that digital interrupt's name instead. |
board |
string | Required | The name of the board the ultrasonic is wired to. You must have a board component configured to make use of the board's pins. |
timeout_ms |
int | Optional | Time to wait in milliseconds before timing out of requesting to get ultrasonic distance readings. Default: 1000 . |