why iam getting inconsistent ultraonic sensor readings for the HC-SRO4

Hullo well i have tried several ultrasonic code even using basic code of pulseln() function and even tried new Ping library but iam still getting erroneous distances readings.
whether i put an obstacle or not, i still get these sets of results. Iam desperate for advice or help about what might be the problem. is it with HC-SRO4 sensors or something confined in the room.
The results below are from using the new Ping library
https://bitbucket.org/teckel12/arduino-new-ping/wiki/Home#!issue-tracking

Ping: 0cm
Ping: 129cm
Ping: 128cm
Ping: 127cm
Ping: 127cm
Ping: 129cm
Ping: 129cm

then when i was not using any library but the pulseln() function to calculate the duration before i calculate the distance of sound.

digitalWrite(trigPin, LOW); //clear the trigPin
     delayMicroseconds(2);
     digitalWrite(trigPin, HIGH);
     digitalWrite(trigPin, LOW);
     //Once received the Echo calculate the distance from the duration
     duration = pulseIn(echoPin, HIGH);
     distance = (duration/2)/29.1 ; //distance in inches..
     //distance = duration/58.2;  ////Calculate the distance (in cm) based on the speed of sound.
     delay(300); //for stability  but they used 300

these are the results.
Distance: 123
Distance: 123
Distance: 123
Distance: 122
Distance: 122
Distance: 124
Distance: 124

I have had no problems with the NewPing library.

  • Are you sure your wires to the device are ok? Worth swapping them for a dfferent set to try.
  • Have you got another sensor to try as it could be hardware problem

yeah you are right, it was my wiring that was incorrect.... i had accidently connected the ultrasonic sensor on the breadboard... positive n negative blue lines instead of the middle part.
It was breadboard connection problem... some friend had pointed at it some time before but just because i was bit busy with the exam period. did not have time to see the forum