I think my HC-SR04 Ultrasonic sensor is broken!

When I run the example code from the manual, it displays a distance of approximately 2-5cm in the serial monitor. Although there is nothing above or around it. Thank you in advance!

I can't see your manual so it might be helpful if you posted the code here. If you typed it in it's awfully easy to make the odd teeny mistake. What Arduino you're using and how the HC-SR04 is connected might also help.

Steve

You’ve got about five of them, haven’t you?

They can’t all be broken, surely.

try my basic test code

#define TriggerPin1 4
#define EchoPin1  2
#define TriggerPin2 5
#define EchoPin2  3
#define ToInch(US) (float) US / 74 / 2
#define ToCent(US) (float) US / 29 / 2

volatile  unsigned long PingTime1;
volatile  unsigned long PingTime2;

int PinMask = B100; // pin 2
float Measurements1;
float Measurements2;
unsigned long TimeoutTimer1;
unsigned long TimeoutTimer2;
void PingTimer1( )
{
  static unsigned long edgeTime;
  
  if (PIND >> 2 & 1) { // Quickly get the state of  pin 2 and test Pulse went HIGH
    edgeTime = micros();        //store the start time micros() return a uint32_t
  } else { // Pulse Went low calculate the duratoin
    PingTime1 = edgeTime - micros(); // Calculate the change in time  NOTE: the "% EchoInputCount" prevents the count from overflowing the array look up % remainder calculation
  }
}
void PingTimer2( )
{
  static unsigned long edgeTime;
  if (PIND >> 3 & 1) { // Quickly get the state of  pin 3 and test Pulse went HIGH
    edgeTime = micros(); //store the start time
  } else { // Pulse Went low calculate the duratoin
    PingTime2 = edgeTime - micros(); // Calculate the change in time  NOTE: the "% EchoInputCount" prevents the count from overflowing the array look up % remainder calculation
  }
}
void debug()
{
  char S[20];
  static unsigned long PingTimer;
  if ((unsigned long)(millis() - PingTimer) >= 100) {
    PingTimer = millis();
    Serial.print(dtostrf(Measurements1, 6, 1, S));
    Serial.print(dtostrf(Measurements2, 6, 1, S));
    Serial.println();
  }
}

void PingTrigger(int Pin)
{
  digitalWrite(Pin, LOW);
  delayMicroseconds(1);
  digitalWrite(Pin, HIGH); // Trigger another pulse
  delayMicroseconds(10);
  digitalWrite(Pin, LOW);
}

void PingIt1()
{
  unsigned long PT;
  static unsigned long PingTimer;
  PingTimer = millis();
  if ( PingTime1 > 0) {
    PT = GetTripTime(); // time it took for sound to travel
    Measurements1 = (float) (ToCent(PT));
  //  Measurements1 = (float) (ToInch(PT));
    debug();
    TimeoutTimer1 = millis() - 9990 ; // set the timout to 9990ms in the past so we Wait 10ms then trigger another pulse.
  }
}
void PingIt2()
{
  unsigned long PT;
  static unsigned long PingTimer;
  PingTimer = millis();
  if ( PingTime2 > 0) {
    PT = GetTripTime(); // time it took for sound to travel
    Measurements2 = (float) (ToCent(PT));
  //  Measurements2 = (float) (ToInch(PT));
    debug();
    TimeoutTimer2 = millis() - 9990 ; // set the timout to 9990ms in the past so we Wait 10ms then trigger another pulse.
  }
}
unsigned long GetTripTime() {
  unsigned long PT;
  cli ();         // clear interrupts flag
  PT = PingTime1;
  PingTime1 = 0;
  PT = PingTime2;
  PingTime2 = 0;
  sei ();
  return PT;
}

void setup()
{
  Serial.begin(115200);
  Serial.println("Ping Test");
  pinMode(EchoPin1, INPUT);
  pinMode(TriggerPin1, OUTPUT);
  pinMode(EchoPin2, INPUT);
  pinMode(TriggerPin2, OUTPUT);
  attachInterrupt(digitalPinToInterrupt(EchoPin1), PingTimer1, CHANGE );
  attachInterrupt(digitalPinToInterrupt(EchoPin2), PingTimer2, CHANGE );

}

void loop()
{
  PingIt1(); // Manage ping data
  PingIt2(); // Manage ping data
  if ( ((unsigned long)(millis() - TimeoutTimer1) >= 1000)) {
    PingTrigger(TriggerPin1); // Send another ping
    TimeoutTimer1 = millis();
  }
    if ( ((unsigned long)(millis() - TimeoutTimer2) >= 1000)) {
    PingTrigger(TriggerPin2); // Send another ping
    TimeoutTimer2 = millis();
  }
}

Z