Henglos IO
Built-in packages

Ultrasonic Sensor

Measures distance with an HC-SR04-style ultrasonic sensor (also JSN-SR04T and other 4-pin modules) — Measure publishes how far the nearest object is, Detect branches on whether something is closer than a threshold.

Measures distance with an HC-SR04-style ultrasonic sensor (also JSN-SR04T and other 4-pin modules) — Measure publishes how far the nearest object is, Detect branches on whether something is closer than a threshold. The HC-SR04's Echo is 5 V: on a 3.3 V board (ESP32) wire it through a voltage divider (e.g. 1 kΩ / 2 kΩ), or use a 3.3 V module.

@henglosio/component-ultrasonicsensorv1.0.0platform ^1.0.0
NodeKindWhat it does
MeasureActionPings and publishes the distance to the nearest object.
DetectActionPings and goes out Near when something is closer than Threshold, Far otherwise (nothing in range counts as Far).

Actions

Measure

Pings and publishes the distance to the nearest object. No echo (nothing in range) goes out Fallback.

Settings

SettingTypeDefaultWhat it's for
Trigger PinPin (digital out)—Board pin wired to the sensor's Trig.
Echo PinPin (digital in)—Board pin wired to the sensor's Echo (through a divider on a 3.3 V board).
UnitOne of: Centimeters, Millimeters, InchesCentimetersUnit of the distance it publishes.
TimeoutNumber30Advanced. How long to wait for the echo, in milliseconds. 30 covers ~5 m; lower it to give up sooner on far objects.
TemperatureNumber20Advanced. Air temperature, in °C — sound travels faster in warm air. 20 is fine indoors.

Publishes

OutputTypeWhat it is
distancefloatDistance to the nearest object, in Unit.
echointHow long the echo took to come back, in microseconds.

Detect

Pings and goes out Near when something is closer than Threshold, Far otherwise (nothing in range counts as Far).

Ends on Near, Far — or Fallback when it can't run.

Settings

SettingTypeDefaultWhat it's for
Trigger PinPin (digital out)—Board pin wired to the sensor's Trig.
Echo PinPin (digital in)—Board pin wired to the sensor's Echo (through a divider on a 3.3 V board).
ThresholdNumber20Closer than this (in Unit) goes out Near.
UnitOne of: Centimeters, Millimeters, InchesCentimetersUnit of Threshold and of the distance it publishes.
TimeoutNumber30Advanced. How long to wait for the echo, in milliseconds. 30 covers ~5 m.
TemperatureNumber20Advanced. Air temperature, in °C — sound travels faster in warm air. 20 is fine indoors.

Publishes

OutputTypeWhat it is
distancefloatDistance to the nearest object, in Unit — only when an echo came back.
nearboolWhether something was closer than Threshold.

On this page