Ultrasonic Sensor has a bug

Dear Dexter,

I installed newly bought Ultrasonic sensor on my GoPiGo2 car. The sensor is working fine in initial testing with basic_test_all.py. However, I found an issue when running basic_obstacle_avoid.py. A lot of times, us_dist(15) returns value wrong, such as 7 or 6 only.

I searched your forum and ran grove_distance_sensor.py to test. The incorrect values were returned quite frequently.

Is this a product defect or standard behavior?

Thanks
-KH

Hi @skywalkersv,

Did you test the sensor with no obstacle, if yes then what values did it return?

Can you also send us the following to help you better

  • Screenshot of the program that you ran and the output that you got.
  • Picture of how you are connecting the Ultrasonic Sensor.

Also follow this guide to generate a test log and upload it with your reply…

-Shoban

Hi Shoban,

Tonight I tried the Ultrasonic sensor again and it works just find and returned correct range values. If, in the future, the sensor does not work correctly, I will apply your diagnose steps to test. For now, please close this thread as problem solved.

Thank you very much for all your help.

Best,
KH

Hi @skywalkersv,

Glad that you have your sensor working, do reach out us if you have any trouble in future.

-Shoban

Hi,

The Ultrasonic sensor issue is shown again. the return value of us_dist(15) is only 6 when there is NO obstacle in the front. Attached please see 3 files:

  • Picture how Ultrasonic sensor is connected to GoPiGo
  • Screenshot of running grove_distance_sensor.py
  • Test log generated from Test & Troubleshooting

Ooops, it says “New users cannot attach attachments” :grimacing:

Thanks,
KH

Hey skywalkersv, I think I upgraded your status so you can post files now. Can you give it a go?

Thanks, John.

Here are attachments:

  • Picture how Ultrasonic sensor is connected to GoPiGo
  • Screenshot of running grove_distance_sensor.py
  • Test log generated from Test & Troubleshooting

Thanks.



log.txt (7.0 KB)

Since the ultrasonic sensor I bought is not reliable, I am wondering if I can have a replacement? Thanks

Hi @skywalkersv,

It looks like you are connecting the Ultrasonic sensor to the Analog Port A1. The example, grove_distance_sensor.py works on the digital port by default. So can you try connecting the sensor to the Digital Port (below the Analog Port) on the GoPiGo and run the example again.

If that doesn’t work, uncomment the line 45 and comment line 44 here to make it work with Analog Port and try the example again by connecting the sensor to analog port.

The sensor was working good previously and now it seems to be not, so can you tell us what all you have tried after it was working.

Please let us know if this helps,
-Shoban

Hi @Shoban,

Thanks a lot for your info. I re-plugged the Ultrasonic sensor to digital port, which is below the analog port. Also changed grove_distance_sensor.py program accordingly. Here is the screenshot.

From the output, you can see that I indeed using digital port, which is 10. However, the return values are occasionally 6, instead of steadily 284. This causes Obstacle Avoider program cannot run smoothly.

Again, is this a product defect?

Thanks.

Hi @skywalkersv,

We are still trying to find out if this is a problem with the sensor or not. So can you post the output that you got with the sensor connected to analog port. Can you also tell us what obstacle and at what distance you placed it in front of the sensor.

Note: Do not forget to make the changes in the code as mentioned here when connecting the sensor to Analog Port.

-Shoban

Hi @Shoban,

The sensor results from both Analog Port and Digital Port are similar (of course, I changed the port number in code accordingly). I pointed the sensor to open space to test and I got results just like shown in the previous screenshot. Most of the time the results are “284” which is correct. But occasionally it returns “6”.

Here is what I suspect: the sensor is not always receiving ultrasound bounce-back wave from straight front. Sometimes it receives from lower down. If I lifted the car high above the ground, the sensor returns correct measurement more consistently. If I leave it on the ground, the measurements become inconsistent. That is why I am wondering if the sensor I bought has defect.

Thanks

Hi @skywalkersv,

Thanks a lot for explaining the problem to us, we are not sure if the Ultrasonic sensor is defective.

What you can try is to tilt the sensor a little upward and place an A4 sheet at 15 cms from the sensor and check if it detects consistently, this test it just to check if the positioning of the sensor is creating any trouble.

We can replace it too, since we aren’t sure if the sensor is defective it might not help.

If you have purchased it directly from us, please contact us through our website here under “General Questions and Feedback”.

If you have purchased from a distributor, then you’ll have to work with your distributor to get a replacement.

-Shoban

Thank you @Shoban , the Ultrasonic Sensor is still not working correctly. I will request for a replacement.

This topic was automatically closed after 24 hours. New replies are no longer allowed.