How to overwrite I2C pin settings Adafruit libs?

Viewed 19

I'm currently trying to run an MLX90614 sensor on a ESP32 board (lolin32 lite) This board doesn't have a pin 21 and from a forum I discovered I can use pin 23 and 19. I tested this out with the I2C scanner code and this works.

Now I like to use Adafruit MLX90614 library and tell it to use pins 23,19.

Adafruit_MLX90614 mlx = Adafruit_MLX90614();
  
void setup() {
   
  // put your setup code here, to run once:
  Serial.begin(115200);
  Wire.end();
  Wire.setPins(23,19);
  Wire.begin();

  delay(100);

  if (!mlx.begin(90, &Wire)) {
    Serial.println("Error connecting to MLX sensor. Check wiring.");
    while (1);
  };
}

I keep getting "Error connecting to MLX sensor. Check wiring" so it doesn't overwrite the pin settings.

Can this been done?

UPDATE: I found my mistake. I had changed the I2C address of the MLX sensor in a previous project. That is why the I2C scanner code worked and Adafruit default address not.

0 Answers
Related