Ultrasonic Sensor Readings

I am wondering if I can get a script that reads distance using ultrasonic sensor. On my gopigo, it works great. But on my grovepi it does not seem to work.

Hi @cubloxia,

Can you try commenting from gopigo import * in your program. That should solve because python sees ultrasonic sensor read function in both GoPiGo and GrovePi libraries. If you wish to use both GoPiGo and GrovePi, then import libraries as import GoPiGo and import GrovePi and then call the ultrasonic function as grovepi.ultrasonicRead(4) .

Please let us know if this helps,

Hi Shoban,
Apparently, it gives me an error. I will post the screenshot as well as the picture of my robot just in case there is something wrong with that.

Hi @cubloxia,

Thanks a lot for the screenshots and pictures. Can you also follow this guide, generate a test log and post it on the forums. Send us a log for both GoPiGo and GrovePi. This log will help us to narrow down to the problem.


Sorry for the late reply…log.txt (6.7 KB)

Hi @cubloxia,

It looks like you have posted the logs only for GoPiGo, can you post it for GrovePi too. If you are using Raspbian for Robots image then you will have to click on the Troubleshooting icon on the Desktop and choose GrovePi in it.


log.txt (6.3 KB)
I am not sure if this is the test log for grovepi

Try running DI_Update (It’s on the desktop) and updating and also select grovepi and update firmware.

Sometimes flashing the firmware fixes it.

the answer is here:


Good luck for your project.

cubloxia, you have an another problem too:
if you use 2 ultrasonic SRF04, you must choose D2 and D4 on your grovepi, because the SRF04 use 2 pins.

on your project, i see, you use connect D3 and D4, it’s impossible.

The SRF04 on D3, use D3 and D4 for the communication.
The SRF04 on D4 use D4 and D5 for the communication.