Need a small help with pyfirmata

Hi, I am trying to connect pyfirmata with Arduino for getting the HC-SR04 sensor data.

PS: StandardFirmata is uploaded to the board already


from pyfirmata import *
import time

port ='COM5'
baud = 57600
board = ArduinoMega(port, baudrate= baud)
trigpin = board.get_pin('d:2:o')
echopin = board.get_pin('d:3:i')


start=0
end=0

trigpin.write(0)
time.sleep(5)


while True:

    trigpin.write(1)
    time.sleep(3)
    trigpin.write(0)


    while echopin.read(0):
        pass
        start = time.time()

    while echopin.read(1):
        pass
        end = time.time()

    

    print((end-start)/58.0*1000000)
    time.sleep(1)

But it seems its not working at all. Says:

Traceback (most recent call last):
  File "D:\Codes\Research\pyth\us.py", line 26, in <module>
    while echopin.read(0):
TypeError: read() takes 1 positional argument but 2 were given

Circuit connection

You should be testing the return value of read(), not passing in what you want the return value to be...

while echopin.read() == 0:

You also do not need those pass statements since you have other statements inside your while loops