Metadata-Version: 2.4
Name: protocentral-tinygsr
Version: 1.0.0
Summary: MicroPython + Raspberry Pi driver for the ProtoCentral tinyGSR galvanic-skin-response breakout (TLA2022-based)
Project-URL: Homepage, https://protocentral.com
Project-URL: Source, https://github.com/Protocentral/protocentral-micropython-tinygsr
Author-email: ProtoCentral Electronics <info@protocentral.com>
License: MIT
License-File: LICENSE.md
Keywords: galvanic-skin-response,gsr,i2c,micropython,protocentral,raspberry-pi,tinygsr,tla2022
Requires-Python: >=3.9
Requires-Dist: protocentral-tla20xx>=1.0
Description-Content-Type: text/markdown

# ProtoCentral tinyGSR — MicroPython + Raspberry Pi

MicroPython driver for the [ProtoCentral tinyGSR breakout](https://protocentral.com/) — 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](https://github.com/Protocentral/protocentral-micropython-tla20xx)** and adds only the tinyGSR configuration and smoothing.

Ported from, and faithful to, the [ProtoCentral tinyGSR Arduino firmware](https://github.com/Protocentral/protocentral_tinygsr) (`firmware/tinygsr/tinygsr.ino`). MIT licensed.

## Install

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

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

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

## Quick start

```python
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):

```python
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](https://github.com/Protocentral/protocentral_tinygsr/tree/main/hardware); 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.
