A cost-effective fabric-embedded resistive soft sensor (ceferss) is an expandable touch matrix sensor with OLED display feedback, featuring optimized performance for fast refresh rates. The theoretical maximum grid size with the current hardware is 13x13 (169 cells), but can be expanded further with a GPIO expander.
This system currently implements a 5x5 capacitive touch matrix sensor with real-time visual feedback, consisting of two main components that communicate over serial:
Core Functionality:
- Matrix Scanning: Implements efficient row-column scanning of a touch grid
- Pin Configuration:
- Rows (GP2-GP6): Output pins for driving the matrix
- Columns (GP7-GP11): Input pins with pull-up resistors for reading
- Touch Detection Logic: Uses inverted logic where
0= touch detected,1= no touch
Performance Optimizations:
- State Change Detection: Only transmits data when the touch state changes, reducing unnecessary serial traffic
- Fast Scanning: 10μs settling delay between row activations for rapid matrix scanning
- Buffered Communication: Uses UART with flushing to ensure immediate data transmission
- High Refresh Rate: Runs at ~50Hz (20ms loop time) for responsive touch detection
- Periodic Sync: Sends full state every 50 iterations (1 second) to maintain synchronization
Data Format: Transmits comma-separated values representing the entire 25-cell grid state
Core Functionality:
- Serial Communication: Receives touch data from Pico over USB serial at 115200 baud
- OLED Display: Renders real-time grid visualization on SH1106 OLED display via I2C
- Grid Rendering: Draws 5x5 grid with filled squares for touched cells, empty for untouched
Performance Optimizations:
- Smart Redrawing: Only redraws the display when grid state actually changes
- Non-blocking Serial: Uses 0.1s timeout to prevent hanging on missing data
- Efficient Rendering: Pre-calculates grid positioning and uses canvas buffering
- High Responsiveness: 50Hz loop rate (20ms) for near real-time visual feedback
- Error Handling: Robust handling of incomplete serial data and Unicode errors
Visual Design:
- Grid Layout: 10px cells with 2px gaps, centered on display
- Touch Indication: White-filled squares for active touches, outlined squares for inactive
- Responsive UI: Immediate visual feedback upon touch detection
- Serial Link: 115200 baud USB serial connection between Pico and Pi
- Data Efficiency: Only transmits on state changes, minimizing bandwidth usage
- Synchronization: Periodic full-state broadcasts ensure system stays in sync
- Touch Detection: Sub-millisecond matrix scanning with 10μs settling time
- Data Transmission: Immediate UART flushing for minimal latency
- Visual Response: 50Hz refresh rate provides smooth, responsive user interaction
- Optimization Strategy: State change detection prevents unnecessary processing on both ends
- Low Latency: Optimized scanning and immediate transmission minimize delay
- Bandwidth Efficient: Change-based updates reduce serial traffic
- Robust Operation: Error handling and periodic sync maintain reliability
- Scalable Architecture: Modular design allows easy modification of grid size or display type
- Raspberry Pi Pico H (with headers for easy connection)
- Raspberry Pi 5 (or compatible Pi model)
- SH1106 OLED Display (I2C interface)
- 5x5 Capacitive Touch Matrix (custom or commercial)
- USB Cable (for Pico-Pi communication)
machine- Hardware interfacetime- Timing functions
serial- Serial communicationluma.core- OLED display core functionsluma.oled- OLED device driverstime- Timing functions
- Serial Port:
/dev/ttyACM0 - Baud Rate: 115200
- I2C Address: 0x3C (OLED display)
- Grid Size: 5x5 (25 cells)
- Cell Size: 10px
- Cell Gap: 2px
- Refresh Rate: 50Hz
- Connect the 5x5 touch matrix to the Pico pins as specified
- Connect the OLED display to Pi's I2C bus
- Connect Pico to Pi via USB
- Upload
pico_grid.pyto the Pico - Run
soft_sense_pico.pyon the Pi - Touch the matrix to see real-time visualization on the OLED display
This architecture achieves a fast, responsive soft sensor suitable for real-time interactive applications, with the Pico handling the time-critical hardware interface while the Pi provides rich visual feedback and potential for additional processing or networking capabilities.