Skip to content

Fixes on 0x69 address detection#10715

Open
oscgonfer wants to merge 19 commits into
meshtastic:developfrom
fablabbcn:bugfix/detection-on-0x69-address
Open

Fixes on 0x69 address detection#10715
oscgonfer wants to merge 19 commits into
meshtastic:developfrom
fablabbcn:bugfix/detection-on-0x69-address

Conversation

@oscgonfer

@oscgonfer oscgonfer commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

This PR fixes some detection issues on devices with shared address 0x69
BMX160 detection has recently been improved by @caveman99, but there was some leftover code that assumed BMX160 as a default if everything else failed. Similar to MPU6050, which a WHO_AM_I register check was added.

The SEN5X sensor detection process is also improved, avoiding a custom probe for the model, but instead using the class methods, which account for all the I2C speed shebang (#9898 and #10593).

Changes:

  • Change SEN5X detection method, using class itself
  • MPU6050 register check
  • BMX160 default removed

🤝 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:
    • Seeed Xiao ESP S3 with SEN5X and other sensors

Tagging @caveman99 for checks if possible with the BMX160 code.

Caution

Rebased onto #9898 and #10593

* Change SEN5X detection method, using class itself
* MPU6050 register check
* BMX160 default removed
@oscgonfer oscgonfer self-assigned this Jun 14, 2026
@oscgonfer oscgonfer requested a review from caveman99 June 14, 2026 11:50
@oscgonfer oscgonfer added tech debt Code or lib references that are not up to date or propper standards hardware-support Hardware related: new devices or modules, problems specific to hardware cleanup Code cleanup or refactor labels Jun 14, 2026
@thebentern thebentern requested a review from Copilot June 14, 2026 12:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR improves I2C device detection on shared address 0x69, removing fallback assumptions and making detection more explicit—especially for SEN5X air quality sensors and MPU6050 IMUs.

Changes:

  • Add a SEN5XSensor::probe(...) method and use it from the I2C scanner instead of a custom product-name probe.
  • Add an MPU6050 WHO_AM_I register value check.
  • Remove the previous “default to BMX160/MPU6050” behavior when detection fails.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/modules/Telemetry/Sensor/SEN5XSensor.h Exposes a new probe(...) API to support scanner-based detection.
src/modules/Telemetry/Sensor/SEN5XSensor.cpp Implements probe(...) by resetting the sensor and identifying the model.
src/detect/ScanI2CTwoWire.cpp Replaces custom SEN5X probing with SEN5XSensor::probe() and adds MPU6050 WHO_AM_I detection while removing old default fallbacks.

Comment thread src/modules/Telemetry/Sensor/SEN5XSensor.cpp Outdated

bool SEN5XSensor::probe(TwoWire *bus, uint8_t address, ScanI2C::I2CPort port)
{
LOG_INFO("SEN5X: probing sensor");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Accepted

Comment thread src/modules/Telemetry/Sensor/SEN5XSensor.cpp Outdated
Comment on lines +140 to 145
#include "../modules/Telemetry/Sensor/SEN5XSensor.h"
bool probeSEN5X(TwoWire *i2cBus, uint8_t address, ScanI2C::I2CPort port)
{
uint8_t cmd[] = {0xD0, 0x14};
uint8_t response[48] = {0};

i2cBus->beginTransmission(address);
i2cBus->write(cmd, 2);
if (i2cBus->endTransmission() != 0)
return "";

delay(20);
if (i2cBus->requestFrom(address, (uint8_t)48) != 48)
return "";

for (int i = 0; i < 48 && i2cBus->available(); ++i) {
response[i] = i2cBus->read();
}

char productName[33] = {0};
int j = 0;
for (int i = 0; i < 48 && j < 32; i += 3) {
if (response[i] >= 32 && response[i] <= 126)
productName[j++] = response[i];
else
break;

if (response[i + 1] >= 32 && response[i + 1] <= 126)
productName[j++] = response[i + 1];
else
break;
}

return String(productName);
SEN5XSensor sen5xsensor = SEN5XSensor();
return sen5xsensor.probe(i2cBus, address, port);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not quite sure I agree with this. I understand the module coupling, but there are two considerations:

  1. The sensor has quite a bit of details that are handled in the class directly (changing bus speed when sending commands, for one) that would need to be replicated in a separate class
  2. The sensor also has an internal firmware versioning, which is also detected in the class. If in the future there are new firmware versions for the sensor, we would only need to update de class, and not the probing on a different function.

@github-actions github-actions Bot added the bugfix Pull request that fixes bugs label Jun 14, 2026
@github-actions

github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

⚡ Try this PR in the Web Flasher

Flash this PR in the Web Flasher

firmware commit boards expires

Warning

This is an automated, unreviewed CI test build. Back up your device configuration
before flashing, and only flash devices you are able to recover.

Supported boards built by this PR (24)
Device Board Platform
Crowpanel Adv 3.5 TFT elecrow-adv-35-tft esp32-s3
Heltec HT62 heltec-ht62-esp32c3-sx1262 esp32-c3
Heltec Mesh Node 096 heltec-mesh-node-t096 nrf52840
Heltec Mesh Node T1 heltec-mesh-node-t1 nrf52840
Heltec Mesh Node T114 heltec-mesh-node-t114 nrf52840
Heltec V3 heltec-v3 esp32-s3
Heltec V4 heltec-v4 esp32-s3
Raspberry Pi Pico pico rp2040
Raspberry Pi Pico W picow rp2040
RAK WisMesh Tag rak_wismeshtag nrf52840
RAK WisBlock 11200 rak11200 esp32
RAK WisBlock 11310 rak11310 rp2040
RAK3312 rak3312 esp32-s3
RAK WisBlock 4631 rak4631 nrf52840
Seeed Wio Tracker L1 seeed_wio_tracker_L1 nrf52840
Seeed Xiao NRF52840 Kit seeed_xiao_nrf52840_kit nrf52840
Seeed Xiao ESP32-S3 seeed-xiao-s3 esp32-s3
Station G2 station-g2 esp32-s3
Station G3 station-g3 esp32-s3
LILYGO T-Deck t-deck-tft esp32-s3
LILYGO T-Echo t-echo nrf52840
LILYGO T-Echo Plus t-echo-plus nrf52840
LilyGo T3-C6 tlora-c6 esp32-c6
Seeed SenseCAP T1000-E tracker-t1000-e nrf52840

Build artifacts expire on 2026-07-14. Updated for f604a4e.

@github-actions

Copy link
Copy Markdown
Contributor

Firmware Size Report

22 targets | vs develop: 21 increased, 1 decreased, net +206,128 (+201.3 KB)

Target Size vs develop
picow 1,245,312 📈 +24,452 (+23.9 KB)
pico2w 1,220,880 📈 +23,504 (+23.0 KB)
rak11310 806,536 📈 +23,352 (+22.8 KB)
pico 783,912 📈 +23,320 (+22.8 KB)
seeed_xiao_rp2040 782,104 📈 +23,296 (+22.8 KB)
Show 17 more target(s)
Target Size vs develop
seeed_xiao_rp2350 769,248 📈 +22,624 (+22.1 KB)
pico2 771,088 📈 +22,616 (+22.1 KB)
seeed-xiao-s3 2,250,880 📈 +4,448 (+4.3 KB)
rak3312 2,246,816 📈 +4,352 (+4.2 KB)
rak11200 1,835,360 📈 +4,144 (+4.0 KB)
heltec-ht62-esp32c3-sx1262 2,111,104 📈 +4,128 (+4.0 KB)
rak3172 176,304 📉 -3,996 (-3.9 KB)
station-g3 2,241,216 📈 +3,872 (+3.8 KB)
tlora-c6 2,344,720 📈 +3,840 (+3.8 KB)
heltec-v3 2,239,408 📈 +3,744 (+3.7 KB)
t-deck-tft 3,785,744 📈 +3,712 (+3.6 KB)
heltec-vision-master-e213-inkhud 2,198,688 📈 +3,120 (+3.0 KB)
t-eth-elite 2,465,136 📈 +3,104 (+3.0 KB)
elecrow-adv-35-tft 3,391,152 📈 +3,024 (+3.0 KB)
heltec-v4 2,259,024 📈 +2,816 (+2.8 KB)
station-g2 2,249,504 📈 +2,576 (+2.5 KB)
wio-e5 232,756 📈 +80

Updated for f8bb8cb

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 cleanup Code cleanup or refactor hardware-support Hardware related: new devices or modules, problems specific to hardware tech debt Code or lib references that are not up to date or propper standards

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants