diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index c363db1b5..ceb7369f8 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -28,6 +28,7 @@ class ScanI2C INA219, INA3221, MAX17048, + MAX17261, MCP9808, SHT31, SHT4X, diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index 9781cbf56..080e67429 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -413,6 +413,19 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize) #else SCAN_SIMPLE_CASE(PMSA0031_ADDR, PMSA0031, "PMSA0031", (uint8_t)addr.address) #endif + case MAX1704X_ADDR: + // Try to read the MAX17261 DevName register 0x21 first + // See: + // https://www.analog.com/media/en/technical-documentation/user-guides/max1726x-modelgauge-m5-ez-user-guide.pdf + registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x21), 2); + if (registerValue == 0x3340) { + logFoundDevice("MAX17261", (uint8_t)addr.address); + type = MAX17261; + } else { + logFoundDevice("MAX17048", (uint8_t)addr.address); + type = MAX17048; + } + break; case BMA423_ADDR: // this can also be LIS3DH_ADDR_ALT registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x0F), 2); if (registerValue == 0x3300 || registerValue == 0x3333) { // RAK4631 WisBlock has LIS3DH register at 0x3333 @@ -431,7 +444,6 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize) SCAN_SIMPLE_CASE(TSL25911_ADDR, TSL2591, "TSL2591", (uint8_t)addr.address); SCAN_SIMPLE_CASE(MLX90632_ADDR, MLX90632, "MLX90632", (uint8_t)addr.address); SCAN_SIMPLE_CASE(NAU7802_ADDR, NAU7802, "NAU7802", (uint8_t)addr.address); - SCAN_SIMPLE_CASE(MAX1704X_ADDR, MAX17048, "MAX17048", (uint8_t)addr.address); SCAN_SIMPLE_CASE(DFROBOT_RAIN_ADDR, DFROBOT_RAIN, "DFRobot Rain Gauge", (uint8_t)addr.address); SCAN_SIMPLE_CASE(LTR390UV_ADDR, LTR390UV, "LTR390UV", (uint8_t)addr.address); #ifdef HAS_TPS65233 diff --git a/src/main.cpp b/src/main.cpp index 8be3bc0ca..60cad4f89 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -708,6 +708,7 @@ void setup() scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA219, meshtastic_TelemetrySensorType_INA219); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::INA3221, meshtastic_TelemetrySensorType_INA3221); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MAX17048, meshtastic_TelemetrySensorType_MAX17048); + scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MAX17261, meshtastic_TelemetrySensorType_CUSTOM_SENSOR); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::MCP9808, meshtastic_TelemetrySensorType_MCP9808); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SHT31, meshtastic_TelemetrySensorType_SHT31); scannerToSensorsMap(i2cScanner, ScanI2C::DeviceType::SHTC3, meshtastic_TelemetrySensorType_SHTC3); diff --git a/src/modules/Telemetry/PowerTelemetry.cpp b/src/modules/Telemetry/PowerTelemetry.cpp index 07c21ac60..f7d773b62 100644 --- a/src/modules/Telemetry/PowerTelemetry.cpp +++ b/src/modules/Telemetry/PowerTelemetry.cpp @@ -186,6 +186,8 @@ bool PowerTelemetryModule::getPowerTelemetry(meshtastic_Telemetry *m) valid = ina3221Sensor.getMetrics(m); if (max17048Sensor.hasSensor()) valid = max17048Sensor.getMetrics(m); + if (max17261Sensor.hasSensor()) + valid = max17261Sensor.getMetrics(m); #endif return valid; diff --git a/src/modules/Telemetry/Sensor/MAX17261Sensor.cpp b/src/modules/Telemetry/Sensor/MAX17261Sensor.cpp index 6ab96aa57..91504a725 100644 --- a/src/modules/Telemetry/Sensor/MAX17261Sensor.cpp +++ b/src/modules/Telemetry/Sensor/MAX17261Sensor.cpp @@ -1,4 +1,4 @@ -#include "MAX17048Sensor.h" +#include "MAX17261Sensor.h" #if !MESHTASTIC_EXCLUDE_I2C && !defined(ARCH_STM32WL) && __has_include() diff --git a/src/modules/Telemetry/Sensor/MAX17261Sensor.h b/src/modules/Telemetry/Sensor/MAX17261Sensor.h index 6f61421dc..f01cf7f58 100644 --- a/src/modules/Telemetry/Sensor/MAX17261Sensor.h +++ b/src/modules/Telemetry/Sensor/MAX17261Sensor.h @@ -1,7 +1,7 @@ #pragma once -#ifndef MAX17048_SENSOR_H -#define MAX17048_SENSOR_H +#ifndef MAX17261_SENSOR_H +#define MAX17261_SENSOR_H #include "configuration.h"