connecting BME280 to Nano

Hi, I’m doing my very first Arduino project and I’m running into some trouble. Im trying to connect a BME280 to my Nano board. The default SDA and SCL pins on this board are assigned to a qwiic connector which I can’t use. So I need to connect it to some other pins. I’m following the steps provided in https://forum.sparkfun.com/viewtopic.php?t=51004 this answer, since it’s basically the problem I have, but I’m running into new problems. My code is this (excluded the loop):

#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme;
TwoWire myWire(3);

void setup() {
  Serial.begin(9600);
  myWire.begin();
  if (!bme.begin(0x76, myWire)) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }
}

and my error is this:

C:\Users\Dave\Documents\Arduino\meh\meh.ino: In function 'void setup()':
meh:14:30: error: no matching function for call to 'Adafruit_BME280::begin(int, TwoWire&)'
   if (!bme.begin(0x76, myWire)) {
                              ^
In file included from C:\Users\Dave\Documents\Arduino\meh\meh.ino:3:
C:\Users\Dave\Documents\Arduino\libraries\Adafruit_BME280_Library/Adafruit_BME280.h:218:8: note: candidate: 'bool Adafruit_BME280::begin(uint8_t, TwoWire*)'
   bool begin(uint8_t addr = BME280_ADDRESS, TwoWire *theWire = &Wire);
        ^~~~~
C:\Users\Dave\Documents\Arduino\libraries\Adafruit_BME280_Library/Adafruit_BME280.h:218:8: note:   no known conversion for argument 2 from 'TwoWire' to 'TwoWire*'
exit status 1
no matching function for call to 'Adafruit_BME280::begin(int, TwoWire&)'

So I’m using the Adafruit library and I don’t understand what’s wrong, I thought I’m doing something that is allowed: https://github.com/adafruit/Adafruit_BM … st.ino#L46 adafruit method.

Would greatly appreciate any kind of help. I’m a Java programmer but the world of Arduino is very new to me!

Looks like bme.begin is looking for the address of a TwoWire object, so try calling it as bme.begin(0x76, &myWire)

/mike

thanks, the program now compiles without any error! It still wouldn’t find my BME280 tho. In the end I fixed it by cutting off a qwiic connector and using that since its the default SCL/SDA pin. Not really ideal but at least it works.

What you want is quite doable, and if you haven’t already, find “Example2_MoreI2CPorts” in the Arduino IDE. I use I2C3 on various boards although can’t remember if I’ve used it on the Nano.

Your code looks good and it should just be a matter of connection to the correct pins - simple hardware issues like that are super annoying.

Reference the Artemis Nano schematic (via Sparkfun product page), you will see that the Qwiic connector uses I2C #2. I2C #3 will use pins 6 (SDA) and 7 (SCL). You also have access to I2C #4 (pins 9 & 10) and #0.