Picar x version Obstacle Avoidance return: distance: -1

~/picar-x/example $ sudo python3 4.avoiding_obstacles.py
distance: -1
distance: -1
distance: -1
distance: -1
It always wend backward

            px.set_dir_servo_angle(-30)
            px.backward(POWER)
            time.sleep(0.5)

distance: -1

It is very likely that the ultrasonic sensor was connected incorrectly.

Could you please double-check the connections?

Black wire — GND

Red wire — 3V3

White wire — D3

Yellow wire — D2

After confirming the wiring is correct, please run the example code again to see how it works.

Obstacle Avoidance wire has no issue as enclosed picture

Black wire — GND
Red wire — 3V3
White wire — D3
Yellow wire — D2

same return -1 result, please assist to resolve the issue

cd ~/picar-x/example
sudo python3 4.avoiding_obstacles.py
distance: -1
distance: -1
distance: -1
distance: -1
distance: -1

with the same connection, I changed to another Obstacle Avoidance device bought from outside, and it worked.

:02:35 2025 from 192.168.1.13
kienchen@raspberrypi:~ $ cd ~/picar-x/example
sudo python3 4.avoiding_obstacles.py
distance: -2
distance: 117.24
distance: 116.75
distance: 116.75
distance: 116.43
distance: 116.3
distance: 116.39

Please contact service@sunfounder.com to provide your detailed address to get a replacement ultrasonic module.