Skip to content

Protocentral/protocentral-micropython-tinygsr

Repository files navigation

ProtoCentral tinyGSR — MicroPython + Raspberry Pi

MicroPython driver for the ProtoCentral tinyGSR breakout — a galvanic-skin-response (electrodermal activity) sensor. The tinyGSR's analog front-end turns skin conductance into a voltage that is digitised by an on-board TI TLA2022 ADC, so this library builds on the TLA20xx driver and adds only the tinyGSR configuration and smoothing.

Ported from, and faithful to, the ProtoCentral tinyGSR Arduino firmware (firmware/tinygsr/tinygsr.ino). MIT licensed.

Install

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

This also installs the protocentral-tla20xx dependency. Raspberry Pi:

sudo raspi-config            # enable I2C
pip install protocentral-tinygsr     # pulls protocentral-tla20xx + smbus2
i2cdetect -y 1               # should show 0x49

Quick start

from machine import Pin, I2C
from protocentral_tinygsr import TinyGSR

i2c = I2C(0, scl=Pin(6), sda=Pin(5), freq=400000)   # QT Py ESP32-C3: SCL=6, SDA=5
gsr = TinyGSR(i2c, address=0x49)   # TLA2022 address is selectable on the breakout
gsr.begin()                  # TLA2022: continuous, 128 SPS, ±0.512 V (as the firmware)
print(gsr.read_filtered())   # 8-tap FIR-smoothed GSR signal

Raspberry Pi — reuses the TLA20xx shim (no separate shim):

from protocentral_tla20xx_linux import I2C
from protocentral_tinygsr import TinyGSR
gsr = TinyGSR(I2C(bus=1), address=0x49); gsr.begin()
print(gsr.read_filtered())

API

Method Purpose
TinyGSR(i2c, address=0x49) construct (creates an internal TLA20XX)
begin() configure the TLA2022 like the firmware (continuous / 128 SPS / ±0.512 V)
read() instantaneous GSR signal, mV
read_filtered() 8-tap FIR-smoothed signal (matches the firmware's streamed value)
.adc the underlying TLA20XX for advanced use

A note on units

The ProtoCentral firmware streams the filtered ADC value (a proxy for skin conductance via the front-end) to OpenView — it does not compute absolute microsiemens, and neither does this library. Converting to absolute µS would require the front-end transfer function from the tinyGSR schematic; that's left as a documented TODO rather than guessed, to keep the library faithful to the source.

Tests

python3 tests/test_tinygsr.py — mocked-bus tests (firmware-matching config, mV scaling, 8-tap FIR). Needs the sibling protocentral-tla20xx repo on the path.

Reconciled against the tinyGSR firmware: TLA2022 @ 0x49, OP_CONTINUOUS / DR_128SPS / FSR_0_512V, default mux, 8-tap unity-coefficient FIR.

About

MicroPython + Raspberry Pi driver for the ProtoCentral tinyGSR galvanic-skin-response breakout (TLA2022-based)

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages