'UltraSonicSensor' object has no attribute 'pin'

Hi all,

raspi 3b
2018_06_27 rasbian for robots

I have moved on from the dexterOS and onto rasbian for robots - I’m just at very basics at the moment but my ultradistancesensor (googly eyes one), despite seemingly working fine with Bloxter on dexterOS, it does not seem to be working now, on raspbianfor robots.

I have it plugged into I2C.

dist.py looks like:

  1 from easygopigo3 import EasyGoPiGo3
  2 # create an EasyGoPiGo3 object
  3 gpg3_obj = EasyGoPiGo3()
  4
  5 # variable for holding the port to which we have the ultrasonic sensor connected to
  6 port = "I2C"
  7
  8 ultrasonic_sensor = gpg3_obj.init_ultrasonic_sensor(port)
  9
 10 # read the sensor's measured distance as in the previous example
 11 distance_cm = ultrasonic_sensor.read()

and i get the following error:

Traceback (most recent call last):
  File "dist.py", line 8, in <module>
    ultrasonic_sensor = gpg3_obj.init_ultrasonic_sensor(port)
  File "build/bdist.linux-armv7l/egg/easygopigo3.py", line 909, in init_ultrasonic_sensor
  File "build/bdist.linux-armv7l/egg/easysensors.py", line 782, in __init__
  File "build/bdist.linux-armv7l/egg/easysensors.py", line 429, in __init__
  File "build/bdist.linux-armv7l/egg/easysensors.py", line 217, in set_pin
AttributeError: 'UltraSonicSensor' object has no attribute 'pin'

any help would be great, many thanks.

Problem solved:

i wanted gpg3_obj.init_distance_sensor() not ultrasonic_sensor - and no port necessary

thanks all.

1 Like

Glad you figured it out @toast!
Indeed the distance sensor does not use ultrasonic technology. It is much more precise and reliable than the old ultrasonic sensor.
Still, the ultrasonic sensor is part of easygopigo3 as there are many out there.

And congrats on “graduating” from DexterOS to Raspbian for Robots.
Cleo

1 Like