Skip to content

Add SuperScanner and FindSensorPower to drv_multiPinI2CScanner#2160

Open
acuartango wants to merge 1 commit into
openshwprojects:mainfrom
acuartango:feature/superscanner
Open

Add SuperScanner and FindSensorPower to drv_multiPinI2CScanner#2160
acuartango wants to merge 1 commit into
openshwprojects:mainfrom
acuartango:feature/superscanner

Conversation

@acuartango

Copy link
Copy Markdown

Title: Add SuperScanner and FindSensorPower to I2C Scanner for undocumented devices

Description: This PR introduces two powerful brute-force I2C hardware discovery commands into drv_multiPinI2CScanner.c. These tools are specifically designed to help the community reverse-engineer undocumented Tuya devices where the I2C pins (and sensor power pins) are unknown.

Often, manufacturers connect sensors (like temperature/humidity) to random GPIOs and power them dynamically via another GPIO. Finding these manually without hardware tracing is extremely tedious.

Changes
Added two new console commands registered in MultiPinI2CScanner_Init():

  1. FindSensorPower <sda_pin> <scl_pin>

Purpose: Finds the dynamic power GPIO for an I2C sensor when the SDA and SCL pins are already known.
How it works: It iterates through all available GPIOs (excluding UART and the provided I2C pins). For each GPIO, it tests both Active-High and Active-Low power states. It applies the state, waits 100ms, and probes standard environmental sensor addresses (0x38, 0x40, 0x44, 0x45). If an ACK is received and valid data is read, it reports the power pin and its active state to the console.
2. SuperScanner

Purpose: A complete, hands-off brute-force discovery tool for unknown hardware.
How it works: It tests over 108,000 combinations of [Power Pin] x [SDA Pin] x [SCL Pin].
It iterates through three power states: No Power Pin, Active-High, and Active-Low.
It safely configures internal pull-ups for testing SDA/SCL pairs.
It includes I2C Bus Clear logic (if SDA is held low, it pulses SCL up to 18 times) to prevent hung buses from halting the scan.
It probes standard sensor addresses (0x38, 0x40, 0x44, 0x45) and double-checks with a dummy read to avoid false positives.
Logs the successful combination of Power, SDA, and SCL pins to the console.
Motivation
During the porting of a new undocumented generic Tuya CHT83XX sensor device (early 2026 revision), the hardware ID was reading as 0xFFFF. It turned out the I2C lines were simply floating because the default pins were incorrect and the sensor required a specific GPIO to be driven high to power on. These tools successfully brute-forced the correct pinout, saving hours of manual multimeter tracing.

Integrating this into the generic multiPinI2CScanner driver makes it available for anyone compiling with ENABLE_MULTIPINI2CSCANNER, without bloating default builds or specific sensor drivers.

All has been fully IA generated, but is tested to get running a new Tuya device. I hope it helps

@acuartango acuartango force-pushed the feature/superscanner branch from b484b10 to 580d92e Compare July 8, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant