Increasing HC-SR04 sensor sensativity?

Goal - I wish to use the HC-SR04 sensor, hidden to the side of my driveway, to detect people as they walk past it and then have the Arduino activate some relays.

Current status -
Using the ample instructions and examples found in these forums I have the HC-SR04 up and running. For the bench test I have it activating LEDs instead of relays.
The HC-SR04/Arduino can "see" the wall across the room and returns an accurate enough distance reading. If I put my hand in front of the sensor (located there at the work bench with me) I get a pretty accurate reading for the distance I can reach.

Problem - walking past the sensor through what I would assume is it's "cone of detection", I get very disappointing results. 99.5% of the time I might as well be a ghost. If I get 2 or 3 feet from it and stand still directly in front of it, it will see me "most" of the time. Even walking directly at it, it very seldom "detects" me.

Question - is there some way to increase the sensor sensitivity?

Thanks.
Gary

Could be your code (...which after 39 posts you should know that you should include in your question....) because if you are using pulseIn with its default one second timeout, most of the time the sensor is deaf, dumb, and blind. You could fix that.

Or, it could be because the ultrasound doesn't reflect well off of a clothed human (and maybe not well off of an unclothed one, either). Can't fix that.

An IR beam break sensor would be more reliable.

Thanks for the input Dave.

The code seemed to be working but I'll be happy to include it here.
I have looked for the 1 sec delay you spoke of in the sensor section but I cannot find it. Just the 2 and 10 microsec delays.
There are 3 "if" statements it runs between sensor readings but I can't imagine those take more then a few milliseconds. When it DOES detect a change in distance, it runs some code that DOES contain delays but by that point the sensor has done it's job and for about 45seconds I am unconcerned with getting further readings until that time has expired.

Anyway - here is the code

    /*
    * 
    *Driveway detection and relay activation
    * 
    * In current development phase, LED are used insted of relays.
    *
    */
    // defines pins numbers
    const int trigPin = 9;
    const int echoPin = 10;

    const long fogRest = 30000; //how long to rest between guest fog
    const long fogRun = 12000; //how long the guest fog should be
    const long driveWalk = 90000; // lenght of time before turning off lights
    
    // defines variables
    long duration;
    int distance;
    int allClear = 8;
    int detect = 7;
    int driveFog = 4;
    int lamp1 = 1;
    int lamp2 = 2;
    int lamp3 = 3;

    int motion = 0;

    unsigned long previousMillis = 0;
    unsigned long previousOn = 0;
    
    
    void setup() {
    pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
    pinMode(echoPin, INPUT); // Sets the echoPin as an Input
     
    pinMode(driveFog, OUTPUT);
    pinMode(lamp1, OUTPUT);
    pinMode(lamp2, OUTPUT);
    pinMode(lamp3, OUTPUT);

    pinMode(detect,OUTPUT);    //led indicator light
    pinMode(allClear,OUTPUT); //led indicator light

    digitalWrite(driveFog, HIGH);
    digitalWrite(lamp1, HIGH);
    digitalWrite(lamp2, HIGH);
    digitalWrite(lamp3, HIGH);

    digitalWrite(allClear,HIGH); //start with green LED on
    digitalWrite(detect,LOW); //start with green LED on

    Serial.begin(9600); // Starts the serial communication
    }
    
    void loop() {
      
    unsigned long currentMillis = millis();

    Serial.print("Fog Run: ");
    Serial.println(currentMillis - previousOn);
    
 // this section turns off fog after 12sec running  
    if (currentMillis - previousMillis >= fogRun) {
            digitalWrite(detect,LOW);  //turn off fog/led 
            digitalWrite(allClear,HIGH); // green LED on   
            motion = 0; //resets guest sensing
            Serial.println("finished smoking");   }
    
    //this section looks for guests
    //+++++++++++++++++++++++++++
    // Clears the trigPin
    digitalWrite(trigPin, LOW);
    delayMicroseconds(2);
    // Sets the trigPin on HIGH state for 10 micro seconds
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin, LOW);
    // Reads the echoPin, returns the sound wave travel time in microseconds
    duration = pulseIn(echoPin, HIGH);
    // Calculating the distance & converting to inches.
    distance= (duration*0.0135/2);
    
    // Prints the distance on the Serial Monitor
    Serial.print("Distance: ");
    Serial.println(distance);

    Serial.print("CurrentMillis: "); //added for code testing
    Serial.println(currentMillis); //added for code testing

    Serial.print("previousMillis: ");//added for code testing
    Serial.println(previousMillis);//added for code testing

    Serial.print("Fog Rest: "); //added for code testing
    Serial.println(currentMillis - previousOn);//added for code testing

    Serial.println("  ");
    Serial.println(" ");
    
    //If NO ONE is detected light green led and turn off blue LED
    if(distance > 110){
    //digitalWrite(allClear,HIGH);
    //digitalWrite(detect,LOW);     
    }

    // MOTION DETECTED - 
    if(distance <= 110 && motion == 0){
    previousMillis = currentMillis;  // save the last time fog came on 
    Serial.print("previousMillis: ");
    Serial.println(previousMillis);

    // check to see how long fogger has been off
    if (currentMillis - previousOn >= fogRest){
          digitalWrite(driveFog, LOW); //drive fog on
          previousOn = currentMillis;  //  
          motion = 1; //makes software ignore new guests until smokes stops     
          digitalWrite(allClear,LOW); //turn off green LED
          digitalWrite(detect,HIGH);  //turn on blue LED
          } 
     else {
          digitalWrite(driveFog, HIGH); //drive fog off
          }
         //lamp sequence
    delay(500);
    digitalWrite(lamp1, LOW);
    delay(1000);
    digitalWrite(lamp2, LOW);
    delay(1000);
    digitalWrite(lamp3, LOW);

    if (currentMillis - previousOn >= driveWalk) {
    digitalWrite(lamp3, HIGH);
    delay(2000);
    digitalWrite(lamp2, HIGH);
    delay(2000);
    digitalWrite(lamp1, HIGH);
  }
    Serial.print("Motion "); //added for code testing
    Serial.println(motion);//added for code testing

    Serial.print("previousOn: ");//added for code testing
    Serial.println(previousOn);//added for code testing
    
    Serial.print("  ");
    Serial.println(" ");

   // delay(500);

      delay(20);
 
    }     
   
    
    }

try my library, it has built in adjustment for pulseIn() timeout.

/*
HCSR04(trigger, echo, temperature, distance)
trigger - trigger pin
echo - echo pin
temperature - ambient temperature, in C
distance - maximum measuring distance, in cm
*/
HCSR04 ultrasonicSensor(9, 8, 20, 300);

where "maximum measuring distance, in cm" is pulseIn() timeout

Gary_Arduino:
I have looked for the 1 sec delay you spoke of in the sensor section but I cannot find it.

Focus your faculties on this:

DaveEvans:
...if you are using pulseIn with its default one second timeout...

There is no need to use a library: just fix the pulseIn timeout.

But you still may have the "sound doesn't bounce well off of clothing" problem.

DaveEvans:
Focus your faculties on this:

There is no need to use a library: just fix the pulseIn timeout.

But you still may have the "sound doesn't bounce well off of clothing" problem.

OK -
I've now read a bunch of posts on pulseIn and if I understand what I was reading, I just need to change the following

 duration = pulseIn(echoPin, HIGH);

to something like -
 duration = pulseIn(echoPin, HIGH, 250000);

Where the "250000" is the timeout in microseconds.

As to the "soft target" issue ... maybe I can point the sensor in a way that will maximize target exposure.
Other than that ... I'm out of luck.
I went with audio sensors as opposed to optical sensors because I thought the hardware setup would be simpler. I was also concerned that the fog I will be deploying might interfere with optical sensors.

The HC-SR04 is extremely cheap but does not work nearly as well as it could. Unfortunately, fixing those problems requires a fair bit of technical expertise.

You would be much better off buying a far higher quality sonar ranging module from Maxbotix. Those really are the best available to hobbyists.

Gary_Arduino:
... if I understand what I was reading, I just need to change the following

 duration = pulseIn(echoPin, HIGH);

to something like -
duration = pulseIn(echoPin, HIGH, 250000);

Where the "250000" is the timeout in microseconds.

Yes, except for the fastest performance, the timeout should not exceed 2 x max range / speed of sound in air, where max range = min(max expected distance to your target, HC-SR04 max range).

quick question. why 99.99% of HC-SR04 code put triger pin LOW for 2us-5us?

// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);

the datasheet tells to set trigger pin HIGH for 10us..100us to start measurement. why LOW?

enjoyneering:
quick question. why 99.99% of HC-SR04 code put triger pin LOW for 2us-5us?

// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);

the datasheet tells to set trigger pin HIGH for 10us..100us to start measurement. why LOW?

This question, which appears to have little or nothing to do with the OP's issue, was cross-posted in NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.7 - Sensors - Arduino Forum

(And it seems just a bit ironic that the question was cross-posted in the NewPing Q&A thread.)

DaveEvans:
Focus your faculties on this:

There is no need to use a library: just fix the pulseIn timeout.

Thanks for pointing me in this direction!
Experimenting with that number has led me to believe I should be able to make this work. I will have to adjust the number for the specific spot I end up deploying this to.