Add MAX17261 sensor

This commit is contained in:
Alexander Begoon 2025-05-10 13:11:00 +02:00
parent b326fb76f3
commit a34cfaee33
No known key found for this signature in database
GPG Key ID: 9F7D401F3E061FF5
6 changed files with 20 additions and 4 deletions

View File

@ -28,6 +28,7 @@ class ScanI2C
INA219,
INA3221,
MAX17048,
MAX17261,
MCP9808,
SHT31,
SHT4X,

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -1,4 +1,4 @@
#include "MAX17048Sensor.h"
#include "MAX17261Sensor.h"
#if !MESHTASTIC_EXCLUDE_I2C && !defined(ARCH_STM32WL) && __has_include(<Adafruit_MAX1704X.h>)

View File

@ -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"