GMTROM/Archiv/print_i2c.py

15 lines
376 B
Python
Raw Normal View History

2023-06-13 09:11:36 +02:00
import smbus
bus = smbus.SMBus(1) # I2C-Bus-Nummer
address = 8 # Arduino-Geräteadresse
while True:
data = []
for i in range(8):
buf = bus.read_i2c_block_data(address, i*4, 4) # 4 Bytes (32 Bit) lesen
val = int.from_bytes(buf, byteorder='little') # Bytes in Integer-Wert konvertieren
data.append(val)
# Daten verarbeiten
print(data)