HELP with A02YYUW Waterproof Ultrasonic Sensor

Hi,
I am looking for help with the A02YYUW Waterproof Ultrasonic Sensor that I just received. I am using a Raspberry Pi 4 with Buster installed. I am trying to get some measure, for that I have followed the instruction from the wiki (https://wiki.dfrobot.com/A02YYUW%20Wate ... 1#target_3)
I have enabled UART following this procedure:
Many thanks,
lls
I am looking for help with the A02YYUW Waterproof Ultrasonic Sensor that I just received. I am using a Raspberry Pi 4 with Buster installed. I am trying to get some measure, for that I have followed the instruction from the wiki (https://wiki.dfrobot.com/A02YYUW%20Wate ... 1#target_3)
I have enabled UART following this procedure:
Code: Select all
Then, I have created a test .py file with the following content: Start raspi-config: sudo raspi-config.
Select option 3 - Interface Options.
Select option P6 - Serial Port.
At the prompt Would you like a login shell to be accessible over serial? answer 'No'
At the prompt Would you like the serial port hardware to be enabled? answer 'Yes'
Exit raspi-config and reboot the Pi for changes to take effect.
Code: Select all
Now, when I run this file I get the following output:# -*- coding:utf-8 -*-
'''
# demo_get_distance.py
#
# Connect board with raspberryPi.
# Run this demo.
#
# Connect A02 to UART
# get the distance value
#
# Copyright [DFRobot](https://www.dfrobot.com), 2016
# Copyright GNU Lesser General Public License
#
# version V1.0
# date 2019-8-31
'''
import time
from DFRobot_RaspberryPi_A02YYUW import DFRobot_A02_Distance as Board
board = Board()
def print_distance(dis):
if board.last_operate_status == board.STA_OK:
print("Distance %d mm" %dis)
elif board.last_operate_status == board.STA_ERR_CHECKSUM:
print("ERROR")
elif board.last_operate_status == board.STA_ERR_SERIAL:
print("Serial open failed!")
elif board.last_operate_status == board.STA_ERR_CHECK_OUT_LIMIT:
print("Above the upper limit: %d" %dis)
elif board.last_operate_status == board.STA_ERR_CHECK_LOW_LIMIT:
print("Below the lower limit: %d" %dis)
elif board.last_operate_status == board.STA_ERR_DATA:
print("No data!")
if __name__ == "__main__":
dis_min = 0 #Minimum ranging threshold: 0mm
dis_max = 4500 #Highest ranging threshold: 4500mm
board.set_dis_range(dis_min, dis_max)
while True:
distance = board.getDistance()
print_distance(distance)
time.sleep(0.3) #Delay time < 0.6s
Code: Select all
Can someone please help me to resolve this problem?Traceback (most recent call last):
File "demo_get_distance.py", line 21, in <module>
from DFRobot_RaspberryPi_A02YYUW import DFRobot_A02_Distance as Board
ImportError: No module named DFRobot_RaspberryPi_A02YYUW
Many thanks,
lls