I was able to measure distance using HC-SR04 sensor via C code. (pulseIn function).
Now I want to try this using Python. I see that pyfirmata doesn't seem to have this nice "pulseIn" function that returns the duration in microseconds. So it seems that I have calculate myself... yet it doesn't seem to work... Anyone with any success?
I am using an UNO board and loaded standardFirmata sketch. And connected via MacBook USB to UNO USB.
pin 12 => trigger
pin 8 as Echo (tried 11 as well but same result).
PORT = '/dev/tty.usbmodem411'
it = util.Iterator(board)
sonarEcho = board.get_pin('d:8:i')
sonarTrig = board.get_pin('d:12:o')
for i in range(10):
##### direct write doesnt work either=> board.digital.write(0)
while sonarEcho.read() is None: