PyRaspBeta

← All practice problems

Raspberry Pi practice problem · I²C, SPI, UART & 1-Wire

Config register by hand

MediumBudget $11Python · gpiozero

Skip the driver and talk to the ADS1115 yourself. It has 16-bit big-endian registers chosen by a pointer byte: 0 = conversion result, 1 = config.

To start one conversion of A0 against GND at ±4.096 V full scale, write the config word 0xC383 to register 1 (write_i2c_block_data(0x48, 1, [0xC3, 0x83])): OS=1 (start), MUX=100 (A0), PGA=001 (±4.096 V), MODE=1 (single shot), 128 samples/s. Wait ~10 ms, then read 2 bytes from register 0: a signed code where 32768 = 4.096 V.

Build: a potentiometer between 3V3 and GND, wiper on A0 of an ADS1115 (3V3, I²C pins, ADDR to GND → 0x48).

Program: every 0.5 s print the code and the voltage:

code 10560 = 1.320 V

The test sets the knob to 40 % (1.320 V), then 90 % (2.970 V) at 2 s.

More in I²C, SPI, UART & 1-Wire