[SOLVED] Inconsistent Distance Sensor Readings on GoPiGo3


I’m getting inconsistent distance readings on my GoPiGo3’s distance sensor. At distances greater than 3m it will seemingly randomly report substantially smaller distances. I checked with a tape measure and there’s nothing nearby at those distances, and there seems to be no pattern to it in frequency.

It happens in all the scripts I write, but as an example here’s a script I wrote to test this:

import time
import easygopigo3 as easy

robot = easy.EasyGoPiGo3()
ds = robot.init_distance_sensor()

index = int(input("Enter # of loops: "))
pause = float(input("Enter pause time: "))

for i in range(index):

Here’s an example of the kinds of results I get (this one isn’t printing index the loop is at):

Is it possible for a dust mote to affect the readings? I’m running out of ideas. Any help would be suuuuuuper appreciated! :smiley:

EDIT: Info below to help with troublehsooting.

OS (not Raspian for Robots or DexterOS):

PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION="8 (jessie)"

Hardware Test output:

Manufacturer    :  Dexter Industries
Board           :  GoPiGo3
Serial Number   :  493FB80D514E4C47324B2020FF071D0D
Hardware version:  3.1.3
Firmware version:  0.3.4
Battery voltage :  15.856
5v voltage      :  5.009

Python Version:


Commands used to update GoPiGo3:

sudo sh -c "curl -kL dexterindustries.com/update_gopigo3 | bash"
sudo sh -c "curl -kL dexterindustries.com/update_sensors | bash"

Hello @prideaux74

to help us debug your distance sensor, can I ask you to run another program?

This program is our simplest method of reading the distance sensor.

Does it still return inconsistent values?



Yes it does. I tried in two different locations. Here’s a sample of what I got running it for just a few seconds.

Also, I appreciate the help!


EDIT: Would it be helpful I posted the text instead of the screenshot? Let me know if there’s anything else I can do to help troubleshoot!

Hi @prideaux74,

You’re getting those high values because the distance to the object in front of the sensors is beyond 2.3 meters.

Please take a look at the documentation of the read_mm method here:

You have to orientate the sensor to objects closer than 2.3 meters and then it’s going to work.
Can you confirm us this?

Thank you!


So I grabbed a tape measure and looked into accuracy at different distances, and it basically lines up with what you say.

Approx 1500mm
Readings consistently accurate

Approx 2100mm
Readings accurate 98.8% of the time. (just a single 8190mm reading, no big deal)

Approx 2500mm
100% incorrect, as you said. Either 8190mm or 0mm.

This explains why my script would have it stop seemingly at random with nothing nearby. I had originally had it driving and stopping at distances of 40cm, so those random zeroes when it was >2.3m from the wall caused it stop. This is easy to get around in my script.

Everything seems to be working as you have said. Thank you very much for your time and help, I really appreciate it! Would recommend you guys to my friends.

We could always use a nice review on Amazon! :slight_smile: