Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tof10120 code issue #2

Open
sohilbhr opened this issue Mar 10, 2021 · 0 comments
Open

tof10120 code issue #2

sohilbhr opened this issue Mar 10, 2021 · 0 comments

Comments

@sohilbhr
Copy link

sohilbhr commented Mar 10, 2021

when i try to run this code in my Rpi the sensor can't give me reads every time sometimes move to except what can i do to fix the code?
and sorry for the code itried to put it in code tag but it still appear like this
code:

`import smbus
import time

i2c_ch = 1
i2c_address = 0x52

bus = smbus. SMBus ( i2c_ch )

while True :

try :

    bus. write_byte ( i2c_address , 0 )
    time . sleep ( 0.01 )
   
    b1 = bus. read_byte_data ( i2c_address , 0 )
    b2 = bus. read_byte_data (i2c_address , 1 )
           
    word = ( b1 << 8 ) + b2
    print ( word )

    time . sleep ( 1 )

except OSError :
    print ( 'error' )`

best regards
sohil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant