An article using the HC-SR04 ultrasonic sensor to detect multiple objects at various distances shows a modification to the board of attaching a lead from a pin on one of the ICs on the board calling the data "Raw Echo".

The article is https://create.arduino.cc/projecthub/mircemk/ultrasonic-radar-can-detect-multiple-objects-at-each-ping-7a0f26 which the author says comes from this article https://arduinoplus.ru/arduino-radar/ which my browser can translate into English. The Russian article has the same board modification.

This modification is the same for HC-SR04 and HY-SRF05 ultrasonic sensors and allows multiple echo signals to be detected. If you have an HC-SR04, the integral circuit to which you solder the wire is designated U2.

The image of the board modification is: modified HC-SR504 with lead from IC pin for Raw Echo

A similar modification is done in this lab for multiple object detection using the HC-SR04 https://www.instructables.com/Enhanced-Ultrasonic-Range-Finder/

I would like to understand what this specific IC is and what this pin, which seems to be an output pin from the IC, is doing.

My hunch is that the pin is used on the board to see echoes and some kind of comparator circuit is used so that once the first echo is seen, the board considers job done and the output of the board Echo lead is dropped indicating echo found. Any other echoes that are indicated by the IC pin are ignored. When a Trigger is done on the Trigger pin of the board, the comparator circuit is reset for a new echo detection.

So using the IC Raw Echo pin allows the detection of multiple echoes from a single ultrasonic pulse.

I have found a couple of articles that describe the electronics of the HC-SR04 to some extent including a schematic however I can't understand the schematic versus the physical board.

Several questions about this general topic have been asked:

And this question, which was closed due to lack of clarity, seems to be similar to my question: Analog Signal HC SR04


The Raw Echo lead looks to be attached to pin 10 of the EM78P153S microcontroller which is used to process the signals from the ultrasound receiver circuit of the HC-SR04. A second article with a similar modification explicitly mentions pin 10 however it identifies the actual IC component as U1. The mbed schematic identifies the EM78P153S as U1.

The purpose of this modification is to bypass the signal processing of the EM78P153S and pull the raw signal generated by the ultrasound receiver circuit into another microcontroller, an Arduino in this case, to process the raw signal.

The HC-SR04 schematic https://os.mbed.com/media/uploads/4180_1/hcsr04_schematic.svg identifies U1 as an EM78P153S microcontroller.

detail of HC-SR04 schematic showing EM78P153S microcontroller

This article, https://www.instructables.com/Enhanced-Ultrasonic-Range-Finder/ showing a similar modification mentions pin 10 of U1 as the site for the modification and contains additional information from testing various ranges and with two objects. An oscilloscope was used to trace the raw signal showing the following waveforms. CH1 is from the Echo lead of the HC-SR04 and CH2 is from the Raw Echo lead attached to the pin of the IC.

The initial signal detected on CH2 appears to be the Receiver picking up the ultrasonic burst from the Emitter. The returning echoes seen as as multiple, closely spaced signals on CH2 indicates the echoes are composed of multiple sound waves detected by the Receiver. CH1 show that after a delay so as to eliminate the Emitter's output, the Echo lead is raised to HIGH and held HIGH until a rising edge from the Receiver circuit is seen at which point the Echo lead is then dropped to LOW.

oscilloscope trace of HC-SR04 Echo lead and Raw Echo signal from pin 10 of EM78P153S microcontroller

The Raw Echo signal shows a rising edge when the echo is received with a Vmax of 4.079v which is sufficient to indicate a HIGH on a 5v GPIO pin.

The Arduino source code used for measuring two echoes is as follows. The first object is detected using the Echo lead of the HC-SR04 per standard practice. Once an echo is detected, the code then looks for a second echo by waiting on a HIGH from the Raw Echo lead. Notice the wait between when the first echo is detected on the Echo lead and then checking on a HIGH from the Raw Echo lead. This wait is used to eliminate any of the multiple ripples from the first echo detected as an echo is not a single sound wave but rather multiple, closely space sound waves which causes the Receiver circuit to generate multiple, closely spaced signals.

  // ----- generate 10uS start pulse
  digitalWrite(Trig, HIGH);
  digitalWrite(Trig, LOW);

  // ----- wait for pulse(s) to be sent
  while (!digitalRead(Echo));                 //wait for high
  start_time = micros();

  // ----- set timeout radius
  timeout = start_time + 12000;               //set timeout radius to 2 meters

  // ----- measure first object distance    
  flag = false;
  while (!flag)
    if (!digitalRead(Echo)) flag = true;      //exit loop if object detected
    if (timeout < micros()) flag = true;      //exit loop if timeout exceeded
  finish_time = micros();

  // ----- calculate first object distance
  time_taken = finish_time - start_time;
  Distance1 = ((float)time_taken) / 59;

  // ----- wait for first object echo to finish
  pause = finish_time + 1000;                 //1000uS means 17cm closest object spacing
  while (pause > micros());                   //wait 1000uS (delayMicroseconds(1000) erratic)

  // ----- measure second object distance
  flag = false;
  while (!flag)                               //wait for high
    if (digitalRead(RawEcho)) flag = true;    //exit loop if object dectected
    if (timeout < micros()) flag = true;      //exit loop if timeout exceeded
  finish_time = micros();

  // ----- calculate second object distance
  time_taken = finish_time - start_time;
  Distance2 = ((float)time_taken) / 59;

If this source code were modified to allow for more than two objects being detected, the source code would need to incorporate logic similar to that used for debouncing a simple pushbutton switch. The rising edge would be detected and then any other changes seen on the pin would be ignored for some time period. From the oscilloscope trace, it looks like 1 millisecond should be more than sufficient.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.