Notifications
Clear all
BugOverflow
1
Posty
1
Users
0
Reactions
564
Widok
0
23/06/2021 10:08 pm
Topic starter
how to read data from i2c device? simple script in python
1 Answer
0
23/06/2021 11:08 pm
Topic starter
- create file "test.py" (nano test.py)
- convert to executable file, chmod +x test.py
- edit file, nano test.py
- 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)