Ultra sonic distance sensor with buzzer code - willing to pay

(deleted)

It would be useful if you posted the error message you are seeing.

isn’t it that Tone and NewPing both use timer 2? it’s fairly documented, you can read about how to deal with it online

structure of the code could be like this - not too far from what you have

#define BUZZ_PIN     3
#define MAX_DISTANCE 100 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

// TO DO DECLARE ULTRA-SOUND SENSOR
....;

uint8_t currentPeriod = 0;
uint32_t t0;

void setup() {
  pinMode(BUZZ_PIN, OUTPUT);
  ... ; // TO DO STUFF FOR ULTRA-SOUND SENSOR PINS IF NEEDED
}

void loop() {
  // wait for 30 minutes
  delay(1800000UL);

  // die after 12 periods of 30 min (6 hours)
  if (++currentPeriod > 12) while (true);

  // check presence for 5 minutes
  t0 = millis();
  while (millis() - t0 <= 300000ul) {
    unsigned int distance = ...; // get distance in cm
    if ((distance != NO_ECHO) && (distance <= MAX_DISTANCE)) { // NO_ECHO Value returned if there's no ping echo
      ...; // BUZZ a bit, frequency can depend on currentPeriod if you want variations across periods 
    }
    delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
  }
}