Problems with ultrasonic sensors. The backlight won't turn off. Ultrasonic sensor installation instructions.

False alarms of stairwell lighting when using ultrasonic distance sensors. Ultrasonic sensor installation guidelines.

     Below, we've compiled a comprehensive overview of our experience with ultrasonic sensors over the years and potential challenges associated with their use. Ultrasonic sensors, or ultrasonic distance sensors, are designed to measure the distance to obstacles.

1. Principle of operation.

Ultrasonic sensors operate by emitting a sound wave in the ultrasonic range at a specific frequency and receiving the reflected signal from an obstacle. Knowing the speed of sound and the time it takes for the sound to return, it's easy to calculate the distance traveled by the sound during this time period.

Show more ( To avoid boring the esteemed reader with technical details, we have hidden them under the cut ) 

The sensor uses ultrasound with a frequency of ~40 kHz .
It emits a short ultrasonic pulse that propagates through the air, reflects off an obstacle, and returns to the receiver.

The distance is calculated based on the signal's flight time :

S=(v⋅t)/2

Where:

  • S  is the distance to the object

  • v  is the speed of sound in air (~343 m/s at 20 °C)

  • t  is the time between the emission and reception of the echo

  • dividing by 2 - because the signal goes "there and back"


Ultrasonic Senaor Visualisation2. Sensor design

The sensor is connected using 4 wires:

  • Sensor power supply "+5V", 
  • "GND" or "-" power supply
  •  "Trigger" Tx
  •  "Echo" Rx

The sensor contains:

  • ultrasound transmitter (Tx, emitter),

  • ultrasound receiver (Rx),

  • a controller that generates pulses and measures time.


3. Sequence of work

Step 1. Starting the measurement

A logical “1” with a duration of at least 10 µs is applied to the TRIG pin .

Step 2. Generating ultrasound

Sensor controller:

  • forms a packet of 8 pulses at 40 kHz ,

  • transmits them to the ultrasonic emitter.

Step 3. Wave propagation

Ultrasound:

  • spreads in the air,

  • reflected from a nearby object,

  • returns to the receiver.

Step 4. Receiving the echo

The receiver captures the reflected wave and transmits a signal to the controller.

Step 5. Generating the ECHO signal

A logical "1" appears at the ECHO pin:

  • the beginning of the pulse is the moment of radiation,

  • end - the moment of receiving the reflection.

The pulse duration is directly proportional to the distance.


4. Converting time to distance

The controller calculates the distance. Using the time between the transmitted signal and its reflected echo, the controller calculates the distance to the obstacle  in centimeters : S_cm=t_μs/58 . It then compares this distance with the distance value stored in the controller's memory, which you specified in the settings menu for this sensor or set during calibration. The distance measurement itself is performed by a cycle of several sequential measurements at 50 ms intervals, comparing them with the previous measurement, and filtering out values ​​with questionable results and those significantly different from the others. If all three distance measurements are identical, the obstacle is considered real and detectable, and only then does the stair treads activate. If the values ​​differ, this measurement is ignored and repeated after 200 ms. The hysteresis method used eliminates false alarms.

5. Performance characteristics 

Parameter Meaning
Supply voltage 5 V
Operating frequency 40 kHz
Measurement range ~2 cm – 400 cm
Viewing angle ~15°
Permission ≈ 3 mm
Minimum measurement interval ~60 ms

6. Limitations and features

  • Soft and porous surfaces reflect ultrasound poorly.

  • Inclined surfaces may reflect the signal to the side.

  • Air temperature affects the speed of sound (and accuracy).

  • Does not work in vacuum.

  • False reflections from narrow objects are possible.


 

Problems.

 
 

1. The sensor is installed too low.

The most common problem is that users fail to consider that the ultrasonic sensor emits sound waves in a cone-shaped stream, not in a straight line. Typically, this cone has a sound wave propagation angle of approximately 35 degrees, so when choosing a sensor installation location, careful consideration should be given to the side surfaces near the sensor, the floor, adjacent steps, and other obstacles that may reflect the sound. The diagram shows the sensor's spatial sensitivity, taking into account the sound propagation angle.
       The minimum permissible sensor installation height from the floor (step) depends on the detection range and stair width and can be calculated using the adjacent leg and angle: a = b⋅tan⁡(α), where the adjacent leg (stair width) is b and the angle α (usually 30 degrees), then the opposite leg (installation height) is a. However, to avoid burdening users with complex calculations, we simply recommend maintaining this distance of at least 50 cm. This height is completely sufficient for stairs of any width. See the sketch and video.

2. The sensors are installed opposite each other.

 
A common problem arises when a staircase has multiple flights with a landing and the lighting is equipped with multiple controllers. Placing sensors opposite each other is unacceptable, as the radiation from one sensor will interfere with the operation of the other.
Ultrasonic Senaor ibstalation error
 In this case, it's necessary to use different types of sensors. For example, if ultrasonic sensors are installed on one side, then an infrared sensor should be installed on the other.
Ultrasonic and IR sensor right instalation
You can also install sensors on the railing support (baluster) so they point in opposite directions, if your staircase design allows. In this case, you can use sensors of the same type.
Ultrasonic sensor correct instalations
 

3. Sensors do not work or are triggered randomly.

Wire for ultrasonic sensorSince ultrasonic sensors are digital, high-frequency devices, they are sensitive to the cables used and their length. High-quality shielded copper cables are essential for connecting these types of sensors. The cable shield must be grounded or earthed.
The wire length should not exceed 8 meters; in some cases, up to 10-15 meters is acceptable, provided that high-quality copper wires (not copper-plated bimetallic!) with a cross-sectional area of ​​0.5 mm2 or greater with a copper braided faucet are used. Soldering is mandatory for the connection.
 

4. Sensors do not always register entry to the stairs

Since ultrasonic sensors operate on the principle of reflected sound waves, they cannot detect objects made of sound-absorbing materials. In other words, if you are wearing warm, furry, sound-absorbing clothing, the sensor may not detect you, or it may take longer to detect you. Unfortunately, this is an unsolvable problem based on the sensor's operating principle.

Related Articles