How to use Adafruit libraries with non default I2C pins

EkoEko

New member
Hello,
I have a BMP280 barometric pressure sensor and Teensy 3.6. I want to use this library: https://github.com/adafruit/Adafruit_BMP280_Library
When I use pins 18 and 19 there is no problem, but it doesn't work when I use pins 38 and 38.
I encountered the same problem when I was using <Wire.h> library but solved it by using this library instead of <Wire.h>: https://github.com/nox771/i2c_t3

But I don't know know how can I use Adafruit libraries with non default I2C pins on Teensy 3.6.

I am sorry if there is something missing in the post and thank you in advance.
 
I believe if you are using the Adafruit_BMP280 class, you have the constructor that takes in which Wire object you are using:

like in the example chage: Adafruit_BMP280 bmp; // use I2C interface

to: Adafruit_BMP280 bmp(&Wire1); // use I2C interface on Wire1
 
Relatively simple (I think) just create an instance of bmp passing the correct wire to it. See below:-
Code:
//Use this
Adafruit_BMP280 bmp(&Wire1); // I2C
//Rather than
Adafruit_BMP280 bmp; // I2C
You should note that I have not tested this (I don't have the hardware) but I have examined the Adafruit code and this compiles.
EDIT:
Drat, Kurt beat me to it.
 
Back
Top