Plotting the outgoing ultrasonic signal HC-SR04

hi,

I am using the HC-SR04 supersonic module and would like to visualize its output. The signals going out from Trigger! From my understanding and per datasheet it has to look like that: (see attachment)

Now I took the example sketch and deleted/commented out the - in my opinion - unnecessary lines and altered the Serial.println near the end.

const int trigPin = 9;
//const int echoPin = 10;

//float duration, distance;

void setup() {
  pinMode(trigPin, OUTPUT);
//  pinMode(echoPin, INPUT);
  Serial.begin(9600);
}

void loop() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

//  duration = pulseIn(echoPin, HIGH);
//  distance = (duration*.0343)/2;
//  Serial.print("Distance: ");
//  Serial.print(distance)
Serial.println(digitalRead(trigPin));
  delay(100);
}

But the serial plotter only shows a straight line. See attachment 2.
How can I make the plot look like the signal as shown above?

Thank you!

The HC-SR04 has it's own internal controller. The trigger signal only tells that controller to begin it's program. You will need to tap into some traces on the HC-SR04 circuit board to find such a signal, if it exists.
Paul

Paul_KD7HB:
You will need to tap into some traces on the HC-SR04 circuit board to find such a signal, if it exists.

Indeed it does. Check these out: HC-SR04 | David Pilling and Emil's Projects & Reviews: Making a better HC-SR04 Echo Locator

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.