SEN0151 URM06 Pulse Ultrasonic Sensor With RaspberryPi

userHead Mehmet AliTor 2022-06-21 18:33:46 246 Views1 Replies


I want to use my SEN0151 URM06 Pulse Ultrasonic Sensor with RaspberryPi 3B+. 

However, I couldn't write a proper python code that would make the sensor work correctly. 

With the code I wrote below, the sensor stops after about 3-5 minutes. I couldn't understand why. 


import RPi.GPIO as GPIO

import time
from time import sleep


TRIG = 23
ECHO = 24


GPIO.output(TRIG, True)

while True:

   GPIO.output(TRIG, False)
   GPIO.output(TRIG, True)
   GPIO.output(TRIG, False)
   print ("dalga gonderildi")

   pulse_start = 0
   pulse_end = 0
   while GPIO.input(ECHO)==0:
   pulse_start = time.time()

   while GPIO.input(ECHO)==1:
   pulse_end = time.time()
   print ("olculdu")
   pulse_duration = pulse_end - pulse_start

   mesafe = pulse_duration*100000



I would like your help for a RaspberryPi code similar to the example arduino application in the link below.

2022-06-23 16:44:17

Hi! Did you buy only one module? Does the same code work fine on another sensor?

userHeadPic Tonny12138