Forum

RPI, read register ...
 
Notifications
Clear all

RPI, read register from i2c device

1 Posty
1 Users
0 Reactions
564 Widok
0
Topic starter

how to read data from i2c device? simple script in python

1 Answer
0
Topic starter
  1. create file "test.py" (nano test.py)
  2. convert to executable file, chmod +x test.py
  3. edit file, nano test.py
  4. paste
    #!/usr/bin/env python
    import smbus
    import time
    bus = smbus.SMBus(1)
    address = 0x39
    register = 0x15
    
    b = bus.read_byte_data(address,register)
    print(b)
    bus.close()
    

    where address is result of i2cdetect -y 0 or -y 1,
    where register is location of requested data from Addr (hex)

Odpowiedź

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved
Share: