INA219 and OLED code problem

Hello. I have a problem with displaying the current from the INA219 sensor to my OLED display.

I'm using the following setup: an arduino mini, a INA219 sensor and a OLED 128*64 display.

This is the code that I'm trying to use:

#include #include <Arduino.h>
#include <U8g2lib.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_INA219.h>

Adafruit_INA219 ina219;
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); 

void setup() {
  Serial.begin(9600);
  //ina219.begin();
  u8g2.begin();
  u8g2.setFont(u8g2_font_fur25_tr);
}

void loop() {
  //float current_mA = 0;
  //current_mA = ina219.getCurrent_mA();
  
  u8g2.clearBuffer();          
  u8g2.setCursor(0,25);
  //u8g2.print(current_mA,1);
  u8g2.print("mA");
  u8g2.sendBuffer(); 
    
  //Serial.println(current_mA,1);
  delay(200);
}

With this code on the display I get "mA". The problem is that if I uncomment the "ina219.begin();" from the void setup the display is not lighting up.

Can anyone tell me what am I doing wrong, why am I having this problem?

according to this link: None display when init another IIC device · Issue #27 · olikraus/u8g2 · GitHub

you need to change to the hardware implementation if i2c

blh64:
according to this link: None display when init another IIC device · Issue #27 · olikraus/u8g2 · GitHub

you need to change to the hardware implementation if i2c

Thank you for the link. It was a problem with the constructor.

I was using the U8G2_SH1106_128X64_NONAME_1_SW_I2C constructor. After I changed it to the U8G2_SH1106_128X64_NONAME_1_HW_I2C constructor the problem was gone.