Integration of MAX17043v SparkFun

Hi everybody,

As described here I want to see the remaining battery voltage and energy percentage from an MAX17043 i2c bus sensor connected to an ESP32 board (DFR firebeetle rev4).

But the sensor shows a permanent value for each:

  • 256 % Battery Power
  • 5119 V Voltage

This sadly never changes…
:cry:

I used this ESPhome config with additional MAX17043_component.h as described there.

And this is the actual wiring:

Any suggestions?

Help would be highly appreciated!
THANKS :slight_smile:

Hi. I managed to get my MAX17043 (Sparkfun LiFuelGauge) connected to a Sparkfun ESP32 thing to work, using a different library.

lifuelgauge_sensor.h:

#include "esphome.h"
#include <LiFuelGauge.h>

class LiFuelGaugeSensor : public PollingComponent, public Sensor {
  public:
    // constructor
    Sensor *voltage_sensor = new Sensor();
    Sensor *percentage_sensor = new Sensor();

    LiFuelGauge gauge{MAX17043}; // Create a MAX17043

    LiFuelGaugeSensor() : PollingComponent(15000) {}

    void setup() override {
      // This will be called by App.setup()

      // Battery measurement init
      gauge.reset();
    }
    void update() override {
      // This will be called every "update_interval" milliseconds.
      
      // Get Battery status
      float batt_soc = gauge.getSOC();
      percentage_sensor->publish_state(batt_soc);

      // Get battery voltage
      float batt_volt = gauge.getVoltage();
      voltage_sensor->publish_state(batt_volt);
    }
};

Config yaml:

esphome:
  includes:
    - lifuelgauge_sensor.h
  libraries:
    - Wire
    - "https://github.com/nlamprian/LiFuelGauge"

sensor:
  - platform: custom
    lambda: |-
      auto sensorvalue = new LiFuelGaugeSensor();
      App.register_component(sensorvalue);
      return {sensorvalue->voltage_sensor, sensorvalue->percentage_sensor};
    sensors:
      - name: "Batt V"
        unit_of_measurement: V
        accuracy_decimals: 1
      - name: "Batt Charge"
        unit_of_measurement: "%"
        accuracy_decimals: 1

i2c block seems not required.