-
Notifications
You must be signed in to change notification settings - Fork 1
us_range
The USRangeSensor module is designed to interface with an ultrasonic range sensor (HC-SR04) to measure distances. It provides telemetry data, such as the average distance measured over a configurable number of readings, and integrates with the MicroPython framework.
- Measures distance using the HC-SR04 ultrasonic sensor.
- Calculates and provides the average distance over a configurable number of readings.
- Filters out invalid or out-of-range readings.
- Provides telemetry data for integration with other systems.
- Configurable trigger and echo pins.
The module includes a simple UI in the index.html file:
- Displays the average distance measured in centimeters (
averagecm).
The module uses the HC-SR04 ultrasonic sensor, which requires:
-
Trigger Pin: Configurable via
basicSettings["usrange"]["triggerPinNumber"]. -
Echo Pin: Configurable via
basicSettings["usrange"]["echoPinNumber"].
Ensure the echo pin is protected with a 1k resistor to avoid damage to the microcontroller.
The following settings can be configured in the basicSettings dictionary:
-
triggerPinNumber: The GPIO pin used to send the trigger pulse. -
echoPinNumber: The GPIO pin used to receive the echo signal. -
average_over: The number of readings used to calculate the average distance.
The module provides the following telemetry data:
-
averagecm: The average distance measured in centimeters, rounded to the nearest integer.
Telemetry is only sent if:
- A valid object is detected within the last 5 seconds.
- At least 5 valid readings are available.
This module does not consume any telemetry data.
This module does not provide any commands.
This module does not consume any commands.