HC-SR04 Ultrasonic Sensor Dead Zone

I'm currently finishing up my senior capstone project with a couple of class mates. We have been building an autonomous pick-and-place robot powered by an Arduino. Our task has been to detect a pill bottle that has been placed on the table somewhere, and then bring it to another beacon and drop it off. We are using an HC-SR04 Ultrasonic sensor to detect the pill bottle and beacon, and go to it. However, we are hitting a dead zone with our ultrasonic sensor between 15-20cm. Does anybody have any advice on how we can go about correcting this?

#include <NewPing.h>
 
#define TRIGGER_PIN 10
#define ECHO_PIN 11
#define MAX_DISTANCE 200

// NewPing setup of pins and maximum distance
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); 

void setup() {
   Serial.begin(9600);
}
 
void loop() {
   delay(50);
   unsigned int distance = sonar.ping_cm();
   Serial.print(distance);
   Serial.println("cm");
}

Advice: take out or reduce the delay between the sound transmit and receive.

Paul

Paul_KD7HB:
Advice: take out or reduce the delay between the sound transmit and receive.

Paul

Do you mean how long it waits between each ping?

darnified:
Do you mean how long it waits between each ping?

No. I mean how long it waits for the ping to die out and then switch to receive for the echo.

Paul

Paul_KD7HB:
No. I mean how long it waits for the ping to die out and then switch to receive for the echo.

Paul

I didn't realize this was possible. Are you familiar at all with the <NewPing.h> library?

darnified:
I didn't realize this was possible. Are you familiar at all with the <NewPing.h> library?

Not at all. Is it part of your code you never bothered to post?

Paul

Paul_KD7HB:
Not at all. Is it part of your code you never bothered to post?

Paul

You can read more about it here.

My code is up top.

darnified:
However, we are hitting a dead zone with our ultrasonic sensor between 15-20cm.

I'm not sure I understand. Do you mean that you get correct readings for 10cm and 30cm, but incorrect ones for objects located in the 15-20cm range? Or are you saying that the closest you can measure is at ~15-20cm?

Can you try the "old" ping library and see if you get similar results? It has some limitations, but should confirm if the problem is HW or SW.