Von English mit KI übersetzt ·
„cmd“ ist SMBus-Bezeichnung. Bei einem SMBus-Blockschreibzugriff heißt das erste Byte nach der Adresse Command-Byte, und bei registerbasierten Chips wie dem ADS1115 ist dieses Byte der Registerzeiger. Ihre erste Zeile setzt den Zeiger also auf das Config-Register (0x01) und schreibt darin 0xC3 und dann 0x83. Auf dem Bus: Start, 0x90, 0x01, 0xC3, 0x83, Stopp.0xC383 bedeutet: eine Einzelwandlung starten, AIN0 gegen GND, Messbereich ±4,096 V, Einzelschussmodus, 128 Samples/s. Das Lesen setzt den Zeiger auf 0x00 (Conversion-Register) und liest zwei Bytes.Ihr Fehler liegt in der Byte-Reihenfolge. Der ADS1115 sendet zuerst das höchstwertige Byte, und das Ergebnis ist vorzeichenbehaftet:
data = bus.read_i2c_block_data(0x48, 0x00, 2)
raw = (data[0] << 8) | data[1]
if raw > 0x7FFF:
raw -= 0x10000
volts = raw * 4.096 / 32768
Bei vertauschten Bytes wird eine kleine Änderung im niederwertigen Byte zu einem riesigen Sprung, und genau das ist Ihr 900 gegenüber 52.000. Für AIN1 ändern Sie die MUX-Bits: [0xD3, 0x83]. Und 10 ms reichen bei 128 SPS aus (eine Wandlung dauert etwa 8 ms), die Wartezeit ist also in Ordnung.
„cmd“ is SMBus naming. In an SMBus block write the first byte after the address is called the command byte, and for register-based chips like the ADS1115 that byte is the register pointer. So your first line puts the pointer on the Config register (0x01) and writes 0xC3 then 0x83 into it. On the wire: start, 0x90, 0x01, 0xC3, 0x83, stop.
0xC383 means: start a single conversion, AIN0 against GND, ±4.096 V range, single-shot mode, 128 samples/s. The read sets the pointer to 0x00 (Conversion register) and reads two bytes.
Your bug is the byte order. The ADS1115 sends the most significant byte first, and the result is signed:
data = bus.read_i2c_block_data(0x48, 0x00, 2)
raw = (data[0] << 8) | data[1]
if raw > 0x7FFF:
raw -= 0x10000
volts = raw * 4.096 / 32768
With the bytes swapped, a small change in the low byte becomes a huge jump, which is your 900 vs 52,000. For AIN1 change the MUX bits: [0xD3, 0x83]. And 10 ms is enough at 128 SPS (one conversion is about 8 ms), so the sleep is fine.

