Skip to content

Fix INA226 detection for non-TI compatible chip (Silergy)#10247

Open
theKorzh wants to merge 1 commit intomeshtastic:developfrom
theKorzh:fix-ina226-detection
Open

Fix INA226 detection for non-TI compatible chip (Silergy)#10247
theKorzh wants to merge 1 commit intomeshtastic:developfrom
theKorzh:fix-ina226-detection

Conversation

@theKorzh
Copy link
Copy Markdown

@theKorzh theKorzh commented Apr 22, 2026

Fix incorrect SHTXX detection for INA226-compatible sensor Silergy SQ52201

Problem

Popular cheap INA226-compatible current/power monitor chip Silergy SQ52201 is incorrectly detected as SHTXX (SHT2X).
(These chips are commonly found on modules sold as “INA226” or even misrepresented as TI parts, so users may be unaware they are using Silergy silicon instead of Texas Instruments).

This happens due to strict Manufacturer ID check (only TI 0x5449 accepted)


Root cause

INA2xx-compatible chips do not always use TI's Manufacturer ID:

Device MFG ID DIE ID
INA226 (TI) 0x5449 0x2260
SQ52201 (Silergy) 0x190F 0x0000

Current logic only accepts 0x5449, causing valid compatible devices to fall through to SHT detection.


Changes

  • Extended INA detection to support known compatible MFG IDs

🤝 Attestations

  • I have tested that my proposed changes behave as described.
  • I have tested that my proposed changes do not cause any obvious regressions on the following devices:
    • Heltec (Lora32) V3
    • LilyGo T-Deck
    • LilyGo T-Beam
    • RAK WisBlock 4631
    • Seeed Studio T-1000E tracker card
    • Other: Heltec VisionMaster E213

@github-actions github-actions Bot added the bugfix Pull request that fixes bugs label Apr 22, 2026
@theKorzh
Copy link
Copy Markdown
Author

Closing this PR for now.

It appears that the Silergy SQ52201 is not fully compatible with INA226.

I will revisit logic.

@theKorzh theKorzh closed this Apr 22, 2026
@theKorzh
Copy link
Copy Markdown
Author

Reopening this PR — closed it by mistake.

During additional testing of the SQ52201 support and compatiblity, I accidentally used a defective module unit, which produced incorrect readings and made it look like the changes were broken. The code itself is ready for review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the I2C auto-detection logic to correctly recognize an INA226-compatible Silergy SQ52201 current/power monitor (which shares the 0x40 address with SHT2x sensors), preventing it from being misdetected as an SHT2x device.

Changes:

  • Adds explicit MFG/DIE ID matching for Silergy SQ52201 to be treated as INA226.
  • Refines INA226 vs INA260 identification using both MFG and DIE IDs (for TI INA226) and MFG-only fallback (for TI INA260).
  • Keeps the SHT2x serial-number probe as a fallback when INA IDs don’t match.

Comment on lines +420 to +424
uint16_t mfg = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xFE), 2);
uint16_t die = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0xFF), 2);

if (registerValue == 0x2260) {
logFoundDevice("INA226", (uint8_t)addr.address);
type = INA226;
} else {
logFoundDevice("INA260", (uint8_t)addr.address);
type = INA260;
}
LOG_DEBUG("Register MFG_UID: 0x%x", mfg);
LOG_DEBUG("Register DIE_UID: 0x%x", die);
Copy link
Copy Markdown
Member

@fifieldt fifieldt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants