How raunaqbhirangi/reskin_sensor works
Project type and purpose
• Type: A hardware‑interface Python library with accompanying Arduino firmware, example apps, mechanical designs, and tests.
• Purpose: Provide blocking and non‑blocking APIs to stream data from a ReSkin sensor (MLX90393 on a 5X breakout board) via a microcontroller over USB/serial into Python, plus visualization and test harnesses.
Top‑level file structure and architectural hints
• arduino/
– Contains two .ino sketches for blocking vs burst streaming, plus a submodule for MLX90393 driver code.
• reskin_sensor/
– Python package with sensor.py (ReSkinBase blocking API) and sensor_proc.py (ReSkinProcess non‑blocking API).
• visualizations/
– Example applications: heatmap.py, pygame_demo.py.
• tests/
– Unit tests for both APIs.
• circuits/, parts/
– Mechanical design assets and BOM for the breakout board fixture.
• setup.py, pyproject.toml
– Packaging and dependency declarations.
A. Hardware Layer
– ReSkin 5X sensor board + MLX90393 magnetometer
– Microcontroller (Adafruit Trinket M0 or QT PY) running Arduino firmware
B. Transport Layer
– USB ↔ Serial interface (tty port)
C. Firmware Layer
– Arduino sketches in arduino/ folder
– MLX90393 driver code (git submodule)
D. Host Library Layer
– Python package reskin_sensor
• ReSkinBase: synchronous/blocking data collection
• ReSkinProcess: asynchronous background collection (spawned thread or subprocess, ring buffer)
– Dependencies: pyserial, numpy, etc.
E. Application/Visualization Layer
– visualizations/heatmap.py
– visualizations/pygame_demo.py
F. Testing & CI
– tests/ folder invoking both APIs against a mocked or live sensor
G. Packaging/Deployment
– setup.py and pyproject.toml for pip install, editable installs
H. Mechanical & Circuit Assets
– circuits/ BOM, Gerbers, board design
– parts/ STL files for 3D‑printing holders
Relationships and data flows
• Hardware → Firmware: sensor data read over I2C (MLX90393 → microcontroller).
• Firmware → Host: data streamed over USB/Serial.
• Host → Python API: sensor.py reads serial port (blocking) or sensor_proc.py spawns background thread, buffers data.
• Python API → Application: clients pull or consume data via callback or queue.
• Application → Visualization: data passed into plotting or GUI loops.
• Tests → Python API: exercise both APIs end‑to‑end or via a mock serial port.
• Packaging metadata feeds into pip registry.
Architectural patterns & principles
• Layered architecture: Hardware → Firmware → Transport → Library → Application
• Separation of concerns: blocking vs non‑blocking APIs isolated in separate classes/modules
• Extensibility: clear submodule boundary for sensor driver, room to add new sensor types or microcontrollers
• Packaging: standard Python packaging (PEP 517/518 via pyproject.toml) for easy distribution
• Testability: unit tests decoupled from hardware via mocks or CI‑gateways