Ultrasonic sensor issue

Hi!

I just received the GoPiGo starter kit! It has been FANTASTIC so far!! One issue I am running into is that the Ultrasonic sensor doesn’t seem to work.

I have connected the sensor to the A1 port. The issue is that the sensor always returns a reading between 670 - 675 cm, regardless of the actual distance from objects in front of it. I have tried the basic_test_all.py, basic_obstacle_avoid.py, us_servo_scan.py, and none of these tests are giving me the expected results due to the above issue. I have tried reseating the connections multiple times.

Can you please help?

Thanks,
-Amol

Hey Amol,
Can you try running this example: https://github.com/DexterInd/GoPiGo/blob/master/Software/Python/sensor_examples/grove_distance_sensor.py. There is a variable to set the port on which the ultrasonic sensor is connected on line 44 there. Can you try both the digital and analog ports and see if it works for you.

-Karan

Hi Karan,
I meet the same problem. The reading sensor values are always 670,671,672 no matter where the obstacle is when using function us_dist(15) (because I connect it to A1 port). I have tried your method and find that the print show me that my port is 10 (it should be 15).Then I try us_dist(10) and the reading sensor values become 0 all the time. Can you help me find the solutions, since I have tried to reboot the system, change batteries, re-connect the ultrasonic sensor and even restart my computer as well. None of them solved my problem.
I will appreciate if you can help since ultrasonic sensor is very important to the GoPiGo car.

Hi Rui,
Sorry for taking this long to reply back. I had missed this post. I think we have already shipped a new sensor to you. In the meanwhile it would be great if you could run the troubleshooting script by following the instructions here: https://www.youtube.com/watch?v=ZMadpIEYq5o and upload log to the forums. It would help us to see if there is anything wrong with the software or settings.

-karan

Hi Karan,
Thanks for your reply. Attached is my log.text file. Please have a look at it.

-Rui

Hi Karan,

Thanks for your response. Unfortunately I have not had a chance to run that example yet, but I will do it tonight and get back to you.

Thank you,
-Amol

Hi Karan,

I ran the example you provided. In each case, the obstacle was about 6 inches in front of the ultrasonic sensor.

  1. Sensor connected to A1 and distance_sensor_pin = gopigo.digitalPort

pi@dex ~ $ python grove_distance_sensor.py
0
0
0
0
0
0
0
0

  1. Sensor connected to A1, and distance_sensor_pin = gopigo.analogPort

pi@dex ~ $ python grove_distance_sensor.py
672
673
674
672
672
673
673
672
672

  1. Sensor connected to D11 and distance_sensor_pin = gopigo.digitalPort

pi@dex ~ $ python grove_distance_sensor.py
674
672
672
673
673
672
672
672
673

  1. Sensor connected to D11 and distance_sensor_pin = gopigo.analogPort

pi@dex ~ $ python grove_distance_sensor.py
0
0
0
0
0
0
0
0

Thanks,
-Amol

Hi Karan,

I also ran the troubleshooting script, and the resulting log file is attached.

Thanks,
-Amol

Hey Amol,
Can you run the firmware update on the GoPiGo following the instructions here: http://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/updating-firmware/ and then try running the example again. Also, can you connect the distance sensor to A1 port and give the pin as distance_sensor_pin = 15 and see if that works.

Also, when and from where did you buy the GoPiGo and the ultrasonic sensor and the GoPiGo and has the sensor worked before .

-Karan

Hi Karan,

The link you provided is for the GrovePi, and not for the GoPiGo, so I am assuming its an incorrect link. Please let me know if that is not so.

When I initially set up the GoPiGo, I had followed the instructions to upgrade the firmware: http://www.dexterindustries.com/GoPiGo/getting-started-with-your-gopigo-raspberry-pi-robot-kit-2/5-using-your-gopigo-for-the-first-time/

According to the log_amol.txt file I attached earlier, I am on firmware version 1.6. Isn’t that the latest version? I repeated the firmware update steps, and I am still on version 1.6.

I connected the distance sensor to port A1 and repeated the example, and got the same results as before, even after I explicitly set distance_sensor_pin = 15.

One thing I noticed today is that when I connected the RaspberryPI to the USB power supply for the firmware update, the ultrasonic sensor got pretty warm to touch. It does not warm up this way when the GoPiGo is connected to battery power.

I purchased the GoPiGo directly from the Dexter Industries website. I received it around June 1st, and the ultrasonic sensor has never worked for me.

Thanks,
-Amol

Hey Amol,
Sorry for the wrong link, the reason I was asking for you to run the firmware update was that the i2cdetect was showing a no device on the I2C bus which looked a bit weird. Can you run i2cdetect -y 1 on the terminal and check if you can see a device on 0x08. Also, does everything else work fine on the GoPiGo.

The sensor should not warm up and might be a bad sensor. Thanks for testing it out. I’m really sorry for the frustration.
Can you contact us here, under “General Questions and Feedback”: http://www.dexterindustries.com/site/?page_id=65. We will have one shipped to you immediately. Please post a link to this forum post when you reply us and it would be great if you could send the bad sensor back to us when you receive the newer one so that we can have a look at what went wrong with that one

Again, I’m really sorry to hear about this; we’ll make it right immediately.

-Karan

Karan and Amol,

I was having the same issue with my GoPiGo2. What seems to be the issue is exactly what my father told me: that the ultrasonic sensor is timing out. If you’re sleep counter is too small, then the reading won’t come back accurately. In my case:

time.sleep(.1)

was too small, so in order to fix it, you need to increase the sleep time to .2.

In order to test it, I created a modified version of the Avoider program example, replacing the movements with LED ons an offs and making it never break:

Let me know if you have any questions!

@Midimistro,
Thanks for letting us know about this