Skip to main content

MicroPython + Raspberry Pi driver for the ProtoCentral TLA2022/TLA2024 12-bit I2C ADC breakout

Project description

ProtoCentral TLA20xx MicroPython Library

MicroPython library for the ProtoCentral TLA20xx breakout — a TI TLA2024 / TLA2022 12-bit, 4-channel I²C ADC (ADS101x-class) with a programmable input mux, gain (PGA), and data rate. The same driver also runs on a Raspberry Pi (via a lightweight smbus2 shim), so one codebase covers MCUs (Raspberry Pi Pico, ESP32) and Linux SBCs alike.

Don't have one? Buy it here

Features

  • TI TLA2024 (4-channel) / TLA2022 (1-channel) 12-bit delta-sigma ADC
  • Programmable input mux: 4 single-ended or differential pairs (AIN0–AIN3)
  • Programmable gain / full-scale range from ±6.144 V down to ±0.256 V
  • Selectable data rate, 128 SPS to 3300 SPS
  • Continuous and single-shot conversion modes
  • I²C interface, default address 0x48
  • Qwiic / STEMMA QT connector for solder-free wiring
  • One driver for MicroPython and Raspberry Pi / Linux

Installation

MicroPython (Raspberry Pi Pico, ESP32, …)

Install over the network with mip:

mpremote mip install github:Protocentral/protocentral-micropython-tla20xx

Or copy protocentral_tla20xx.py to the board manually (e.g. mpremote cp protocentral_tla20xx.py :).

Raspberry Pi / Linux

sudo raspi-config            # Interface Options -> enable I2C
pip install protocentral-tla20xx
i2cdetect -y 1               # confirm the ADC shows up at 0x48

Hardware Setup

The board uses I²C. Connect power, ground, and the two I²C lines; the default address is 0x48 (ADDR strap: GND→0x48, VDD→0x49, SDA→0x4A, SCL→0x4B). Set the address in your own script to match the strap. Analog inputs are AIN0–AIN3.

Adafruit QT Py ESP32-C3 (MicroPython)

The examples default to this board — plug the breakout into the STEMMA QT / Qwiic connector for solder-free wiring, or wire it by hand:

TLA20xx Pin QT Py C3 Pin Notes
VIN 3V3 3.3 V supply
GND GND Ground
SDA GPIO5 I2C SDA
SCL GPIO6 I2C SCL

Raspberry Pi Pico (MicroPython)

TLA20xx Pin Pico Pin Notes
VIN 3V3 (OUT) 3.3 V supply
GND GND Ground
SDA GP4 I2C0 SDA
SCL GP5 I2C0 SCL

ESP32 (MicroPython)

TLA20xx Pin ESP32 Pin Notes
VIN 3V3 3.3 V supply
GND GND Ground
SDA GPIO21 default I2C SDA
SCL GPIO22 default I2C SCL

Raspberry Pi (Linux)

TLA20xx Pin RPi Header Notes
VIN Pin 1 (3V3) 3.3 V supply
GND Pin 6 (GND) Ground
SDA Pin 3 (GPIO2 / SDA1) I2C bus 1
SCL Pin 5 (GPIO3 / SCL1) I2C bus 1

Quick Start

MicroPython

import time
from machine import Pin, I2C
from protocentral_tla20xx import TLA20XX, MUX_AIN0_GND, FSR_2_048V, DR_128SPS, OP_CONTINUOUS

i2c = I2C(0, scl=Pin(6), sda=Pin(5), freq=400000)   # Adafruit QT Py ESP32-C3; set pins for your board

TLA20XX_I2C_ADDR = 0x48        # ADDR strap: GND=0x48, VDD=0x49, SDA=0x4A, SCL=0x4B
adc = TLA20XX(i2c, TLA20XX_I2C_ADDR)
adc.begin()
adc.set_mode(OP_CONTINUOUS)
adc.set_dr(DR_128SPS)
adc.set_fsr(FSR_2_048V)        # at +/-2.048 V, 1 LSB ~= 1 mV
adc.set_mux(MUX_AIN0_GND)

while True:
    print("count={:>6}   {:.2f} mV".format(adc.read_adc(), adc.read_voltage()))
    time.sleep(0.5)

Raspberry Pi / Linux

Same driver — swap machine.I2C for the smbus2 shim:

import time
from protocentral_tla20xx_linux import I2C
from protocentral_tla20xx import TLA20XX, MUX_AIN0_GND, FSR_2_048V, DR_128SPS, OP_CONTINUOUS

TLA20XX_I2C_ADDR = 0x48        # ADDR strap: GND=0x48, VDD=0x49, SDA=0x4A, SCL=0x4B

with I2C(bus=1) as i2c:
    adc = TLA20XX(i2c, TLA20XX_I2C_ADDR)
    adc.begin()
    adc.set_mode(OP_CONTINUOUS)
    adc.set_dr(DR_128SPS)
    adc.set_fsr(FSR_2_048V)
    adc.set_mux(MUX_AIN0_GND)
    while True:
        print("count={:>6}   {:.2f} mV".format(adc.read_adc(), adc.read_voltage()))
        time.sleep(0.5)

API Reference

Constructor

Constructor Description
TLA20XX(i2c, address) Create an ADC on a machine.I2C (or Pi shim) bus; address set by the ADDR strap (0x48 default)

Methods

Method Returns Description
begin() Initialise to the default config word (0x8683)
set_mux(MUX_*) Select input channel / differential pair
set_fsr(FSR_*) Set full-scale range / PGA
set_dr(DR_*) Set data rate
set_mode(OP_CONTINUOUS / OP_SINGLE) Set conversion mode
read_adc() int Raw signed 12-bit conversion code (mirrors the Arduino read_adc())
read_voltage() float Convenience: measured voltage in mV (uses the current FSR)

Method and constant names mirror the ProtoCentral TLA20xx Arduino library so sketches translate directly.

Constants

Group Values
Mux MUX_AIN0_AIN1, MUX_AIN0_AIN3, MUX_AIN1_AIN3, MUX_AIN2_AIN3, MUX_AIN0_GND, MUX_AIN1_GND, MUX_AIN2_GND, MUX_AIN3_GND
Full-scale range FSR_6_144V, FSR_4_096V, FSR_2_048V, FSR_1_024V, FSR_0_512V, FSR_0_256V
Data rate DR_128SPS, DR_250SPS, DR_490SPS, DR_920SPS, DR_1600SPS, DR_2400SPS, DR_3300SPS
Mode OP_CONTINUOUS, OP_SINGLE

Examples

Example Platform Description
tla20xx_simpletest.py MicroPython Single-channel read (count + mV)
tla20xx_4channel_scan.py MicroPython Scan AIN0–AIN3 vs GND
tla20xx_raspberrypi.py Raspberry Pi Same read loop using the smbus2 shim

License

Software: MIT License — see LICENSE.md.

Hardware: the TLA20xx breakout board is open-source hardware licensed under CERN-OHL-P v2.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

protocentral_tla20xx-1.0.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

protocentral_tla20xx-1.0.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file protocentral_tla20xx-1.0.0.tar.gz.

File metadata

  • Download URL: protocentral_tla20xx-1.0.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for protocentral_tla20xx-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6464a98e4da1cde0f5d6a1c38ca2c0b1039d61fcbca972ba4d0477f7d8ca9d3f
MD5 a6258bfe3c84d15c52306e1438618ffa
BLAKE2b-256 78c42fbf152ae070b68242ffc741808db22e2e2e154ec55067da855e5edd6325

See more details on using hashes here.

Provenance

The following attestation bundles were made for protocentral_tla20xx-1.0.0.tar.gz:

Publisher: publish.yml on Protocentral/protocentral-micropython-tla20xx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file protocentral_tla20xx-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for protocentral_tla20xx-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 688ca5a56f8026a5d77827f8a79a4950a229b72b4a8890f611b80ad0c326b82e
MD5 224f43f1c8d53725092e89db1863c8b5
BLAKE2b-256 04d3d4239f3f25de61a5df0f25fdb74d734773b17fad636d16cb917d4efb78ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for protocentral_tla20xx-1.0.0-py3-none-any.whl:

Publisher: publish.yml on Protocentral/protocentral-micropython-tla20xx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page