@Sebi
Try this:
messen.py
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
TRIG = 16
ECHO = 12
print "Distance Measurement In Progress"
GPIO.setup(TRIG,GPIO.OUT)
GPIO.setup(ECHO,GPIO.IN)
GPIO.output(TRIG, False)
print "Waiting For Sensor To Settle"
time.sleep(2)
GPIO.output(TRIG, True)
time.sleep(0.00001)
GPIO.output(TRIG, False)
while GPIO.input(ECHO)==0:
pulse_start = time.time()
while GPIO.input(ECHO)==1:
pulse_end = time.time()
pulse_duration = pulse_end - pulse_start
distance = pulse_duration * 17150
distance = round(distance, 2)
print "Distance:",distance,"cm"
GPIO.cleanup()
This worked for me. Made a ShellSensor and called the script.
The underliying r-pi-usonic seems to have problems with the new raspi.
If you run
sudo node node_modules/r-pi-usonic/example/surveyor.js
in “/home/pi/pimatic-app/node_modules/pimatic-ultrasonic” no answer from the sensor will come.