Forum

RPI, read register ...
 
Powiadomienia
Wyczyść wszystko

RPI, read register from i2c device

1 Wpisy
1 Użytkownicy
0 Reactions
668 Widoki
0
Rozpoczynający temat

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

1 odpowiedź
0
Rozpoczynający temat
  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)

Twoja odpowiedź

Nazwa autora

E-mail autora

Twoje zapytanie *

 
Podgląd 0 rewizje Zapisano
Udostępnij: