Canonical Python driver for the TLA2022/TLA2024 ADC breakout — serves MicroPython MCUs and Raspberry Pi from one codebase, per ADR-001. License MIT. This is also the dependency for the tinyGSR driver (tinyGSR is a TLA2024 + GSR front-end; its library wraps this one).
Mirror the ProtoCentral TLA20xx Arduino library (https://github.com/Protocentral/protocentral_tla20XX_arduino): the MUX_*/FSR_*/DR_*/OP_* constants and the begin/setMux/setFSR/setDataRate/setMode/read surface. Register layout follows the TI TLA2024 datasheet.
Driver (protocentral_tla20xx.py) uses only readfrom_mem/writeto_mem. MicroPython passes machine.I2C; Raspberry Pi passes protocentral_tla20xx_linux.I2C (smbus2 shim). Same file both places.
Present: driver, Pi shim, examples (simpletest, 4channel_scan, raspberrypi), mocked-bus + parity tests, package.json (mip), pyproject.toml (PyPI), README, LICENSE.md, publish.yml.
Confirmed from src/protocentral_TLA20xx.{h,cpp} (fully read):
- I2C address: Arduino source hardcodes
0x49; this driver takesaddressas a required constructor arg instead (set per the ADDR strap,0x48board default) ✓ - Registers: CONV
0x00, CONF0x01; 16-bit big-endian I/O ✓ - Methods:
begin(),read_adc(),setFSR(),setMode(),setDR(),setMux()— mirrored 1:1 asbegin/read_adc/set_fsr/set_mode/set_dr/set_mux. read_adc()returns the RAW signed 12-bit code ((int16_t)conv >> 4), not volts. Mirrored exactly; addedread_voltage()as a MicroPython-only convenience (mV via current FSR).- All enum constants confirmed and matched:
DR_128SPS…DR_3300SPS,FSR_6_144V…FSR_0_256V,MUX_AIN0_AIN1…MUX_AIN3_GND,OP_CONTINUOUS/OP_SINGLE. begin()writes config word0x8683(continuous, ±1.024 V, 1600 SPS, AIN0-AIN1) — mirrored literally.
Note: the Arduino setDR() does not clear the DR field before OR-ing (a latent quirk). The MicroPython driver rebuilds the full config word from cached state each call, so DR/MUX/FSR/MODE always reflect the last call — a deliberate, documented improvement over the read-modify-write sequence.
mip install(Pico/ESP32) andpip install protocentral-tla20xx(Pi) both work.- Reads a known input voltage within tolerance on MicroPython and Pi (same driver).
- Negative codes and FSR scaling correct — covered by unit tests.
- Constants/methods/examples line up 1:1 with the Arduino library.
- Mocked-bus + Pi-shim parity tests + ruff green in CI.
protocentral-micropython-tinygsr depends on this package and adds only the GSR conversion (see the first-wave build plan). Keep the public API stable for that consumer.