ullisun58
Well-known member
Today I did some tests with ultrasonic sensors on the Raspberry Pi using a Python script.
I tested the waterproofed JSN-SR04 as well as the HC- SR04. My findings:
The HC SR-04 is cheaper and more accurate than the slightly more expensive JSN-SR04. This sensor can only measure the shortest distance of 20cm. It doesn't provide any valid if the distance is shorter. The HC SR-04 measures minimum distances to 3 cm very reliably. Both sensors deliver valid values up to a distance of 250cm. However, strong reflections occur in the room, which distorts the measurement results. This would still have to be tested outdoors. A disadvantage is that you need 4 GPIOs for 2 sensors. I haven't found a script that uses only one trigger signal yet.
So if I change the ToFs in Ultrasonics Sensors I will use the HC- SR04. But I see in the moment not a great advantage to the VL530X ToF.
Has anybody a solution on Raspberry Pi for 2 Sensors with only one Trigger Signal?
May be this can be a solution
I tested the waterproofed JSN-SR04 as well as the HC- SR04. My findings:
The HC SR-04 is cheaper and more accurate than the slightly more expensive JSN-SR04. This sensor can only measure the shortest distance of 20cm. It doesn't provide any valid if the distance is shorter. The HC SR-04 measures minimum distances to 3 cm very reliably. Both sensors deliver valid values up to a distance of 250cm. However, strong reflections occur in the room, which distorts the measurement results. This would still have to be tested outdoors. A disadvantage is that you need 4 GPIOs for 2 sensors. I haven't found a script that uses only one trigger signal yet.
So if I change the ToFs in Ultrasonics Sensors I will use the HC- SR04. But I see in the moment not a great advantage to the VL530X ToF.
Has anybody a solution on Raspberry Pi for 2 Sensors with only one Trigger Signal?
May be this can be a solution
Code:
while True:
GPIO.output(TRIG, True)
time.sleep(0.00001)
GPIO.output(TRIG, False)
while GPIO.input(ECHO_left)==0:
pulse_start = time.time()
while GPIO.input(ECHO_left)==1:
pulse_end = time.time()
pulse_duration = pulse_end - pulse_start
distance_left = pulse_duration * 17150
distance_left = round(distance+1.15, 2)
GPIO.output(TRIG, True)
time.sleep(0.00001)
GPIO.output(TRIG, False)
while GPIO.input(ECHO_right)==0:
pulse_start = time.time()
while GPIO.input(ECHO_right)==1:
pulse_end = time.time()
pulse_duration = pulse_end - pulse_start
distance_right = pulse_duration * 17150
distance_right = round(distance_right+1.15, 2)
print("Left: ",distance_left,"cm \t Right: ",distance_right,"cm" )
time.sleep(0.2)
Last edited: