I'm receiving this warning:
warnings.warn(DistanceSensorNoEcho('no echo received'))
I've gone through quite a few forums at this point, rearranged the code a dozen times and tried every "this code works foolproof" solution I've encountered. I've checked through the wiring. I'm going to replace the sensor tonight but it hasn't been delivered yet. Am I doing something wrong?Here are pictures of the rasp pi and wiring job. It's not beautiful but it should be getting the job done.Code:
import timefrom time import sleepimport RPi.GPIO as GPIOfrom gpiozero import Robotfrom gpiozero import DistanceSensorfrom gpiozero.pins.pigpio import PiGPIOFactoryimport randomGPIO.setwarnings(False)GPIO.setmode(GPIO.BCM)ultrasonic = DistanceSensor(echo = 7, trigger = 24, pin_factory = PiGPIOFactory()) #threshold_distance = 0.05)print(ultrasonic) while True: print("in loop") print(ultrasonic.distance)
https://drive.google.com/drive/folders/ ... sp=sharing
As background to most troubleshooting, stating what model of RPi board you have and what Operating System it is running would be useful information.
I suggest simply trying the demonstration scripts - and associated cabling - given in the gpiozero documentation.
2.20. Distance sensor - https://gpiozero.readthedocs.io/en/stab ... nce-sensor
Mixing two different GPIO libraries ( gpiozero and RPi.GPIO ) is unwise and unnecessary. Either can do the task. Using both will clash and cause confusion.
Statistics: Posted by B.Goode — Sat Aug 31, 2024 7:55 pm