Add SuperScanner and FindSensorPower to drv_multiPinI2CScanner#2160
Open
acuartango wants to merge 1 commit into
Open
Add SuperScanner and FindSensorPower to drv_multiPinI2CScanner#2160acuartango wants to merge 1 commit into
acuartango wants to merge 1 commit into
Conversation
b484b10 to
580d92e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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():
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