By umutcankalkan
#33721
I just buy this ultrasonic sensor but sample python code does not work with rasbperry pi 4.
Model of sensor : A02YYUW
DataSheet : https://pdf.direnc.net/upload/a02yyuw-s ... asheet.pdf
Errors : Traceback (most recent call last):
File "/home/pi/Desktop/DFRobot_RaspberryPi_A02YYUW-master/raspberry/demo_get_distance.py", line 44, in <module>
distance = board.getDistance()
File "/home/pi/Desktop/DFRobot_RaspberryPi_A02YYUW-master/raspberry/DFRobot_RaspberryPi_A02YYUW.py", line 73, in getDistance
self.measure()
File "/home/pi/Desktop/DFRobot_RaspberryPi_A02YYUW-master/raspberry/DFRobot_RaspberryPi_A02YYUW.py", line 41, in measure
while self.ser.inWaiting() == 0:
File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 590, in inWaiting
return self.in_waiting
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 467, in in_waiting
s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str)
OSError: [Errno 25] Inappropriate ioctl for device
#42052
Hello
I'm trying to run your scripts from https://github.com/DFRobot/DFRobot_RaspberryPi_A02YYUW and getting the following messages:
Traceback (most recent call last):
File "demo_get_distance.py", line 44, in <module>
distance = board.getDistance()
File "/home/pi/Documents/Ultrasonic/DFRobot_RaspberryPi_A02YYUW.py", line 95, in getDistance
self.measure()
File "/home/pi/Documents/Ultrasonic/DFRobot_RaspberryPi_A02YYUW.py", line 63, in measure
while self.ser.inWaiting() == 0:
File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 590, in inWaiting
return self.in_waiting
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 467, in in_waiting
s = fcntl.ioctl(self.fd, TIOCINQ, TIOCM_zero_str)
IOError: [Errno 25] Inappropriate ioctl for device

I also tried to change the file name from AMA0 to S0, but it makes it even worse.
FYI, I'm working with a Pi 3 B+ and the recommended IO Expansion HAT for Raspberry Pi 4B/3B+
Any hints would be helpful.
#42059
Hi, thank you for your support and sorry for the inconvenience caused.
Please note that there are 2 serial ports in RASPBERRY PI 3 and 4, and they will map to the onboard Bluetooth serial port in default.
So please try changing the setting to map to GPIO, which means please map serial0 to ttyAMA0.
The image in the link shows the way to adjust.
By daniel
#45229
Hi, I have same problem as described. If I change oon the file "DFRobot_RaspberryPi_A02YYUW.py" AMA0 to S0, It runs ok but give me a "No data!". Any idea what Im doing wrong?