BMP280 address doesn't show up in Wemos Lolin32(ESP32)

I recently bought a Wemos Lolin32 and a BMP280 for a school project. I'm having no luck connecting BMP280 with Lolin32. I connected,
SDA -> SDA (GPIO 21)
SCL -> SCL (GPIO 22)
VCC to a 3.3v pin
GND to GND

And used two types of I2C detect scripts on it but it does not return an address.
This is the default I2C detect code.

#include <Wire.h>
#include <i2cdetect.h>

void setup() {
  Wire.begin();
  Serial.begin(9600);
  Serial.println("i2cdetect example\n");
  Serial.print("Scanning address range 0x03-0x77\n\n");
}

void loop() {
  i2cdetect();  // default range from 0x03 to 0x77
  delay(2000);
}

Then I used the code below,

#include <Wire.h>
 
void setup() {
  Wire.begin();
  Serial.begin(115200);
  Serial.println("\nI2C Scanner");
}
 
void loop() {
  byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  nDevices = 0;
  for(address = 1; address < 127; address++ ) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0) {
      Serial.print("I2C device found at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
      nDevices++;
    }
    else if (error==4) {
      Serial.print("Unknow error at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0) {
    Serial.println("No I2C devices found\n");
  }
  else {
    Serial.println("done\n");
  }
  delay(5000);          
}

I used the same BMP280 with my nano board and it returned 0x76 as the address but Wemos Lolin32 returns empty in both codes.
What could be the problem? Please help.

Your topic was MOVED to its current forum category as it is more suitable than the original as it is not an Introductory Tutorial

I've been playing with the a Wemos LOLIN32 and random nerd tutorials has been a revelation and life saver too many times.

Take a look at

It just happens to use the BMP280 in some examples of what you might need to do.

I assume you have the right pullup resistors on you I2C bus.

a7

Actually, this was the tutorial that I followed too but after the address scan part, I'm lost cause it returns "No I2C devices found".

And now I have no clue what to do next. :frowning_face:

Did you just stop reading there? That tutorial goes on to suggest and demonstrate the use of alternate pins… might be worth trying.

My trouble with the LOLIN32 is not having a good idea yet of what GPIO pins are used - mine has a build-in OLED and I won't ever admit to how long trying to use digital 16 was making trouble only to finally realize it is used as the OLED reset. :expressionless:

a7

I read the rest of it. But still, I can't wrap my head around the way to change the default SCL and SDA pins to scan for the address.

#include <Wire.h>
#include <i2cdetect.h>

#define I2C_SDA 33
#define I2C_SCL 32

TwoWire I2CBMP = TwoWire(0);

void setup() {
  I2CBMP.begin(I2C_SDA, I2C_SCL);
  Wire.begin();
  Serial.begin(9600);
  Serial.println("i2cdetect example\n");
  Serial.print("Scanning address range 0x03-0x77\n\n");
  
}

void loop() {
  i2cdetect();
  delay(2000);
}

I tried changing default pins like this but it also gives no result.

That looks plausible.

Please say you have or there are already placed pull-up resistors for the I2C lines.

I'm away from my laboratory but this looks like something I'll want to do soon enough, so L8R maybe you will be helping me…

a7

just connected a BME280 to a WeMos Lolin32 pins GPIO22 SCL GPIO21 SDA
the I2C scanner reports

I2C scanner. Scanning ...
 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xA 0xB 0xC 0xD 0xE 0xF 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B 0x1C 0x1D 0x1E 0x1F 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37 0x38 0x39 0x3A 0x3B 0x3C 0x3D 0x3E 0x3F 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57 0x58 0x59 0x5A 0x5B 0x5C 0x5D 0x5E 0x5F 0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67 0x68 0x69 0x6A 0x6B 0x6C 0x6D 0x6E 0x6F 0x70 0x71 0x72 0x73 0x74 0x75 0x76
Found address: 118 (0x76)
 0x77Done.
Found 1 device(s).

and a run of test code

Temperature = 18.20 *C
Pressure = 1032.59 hPa
Approx. Altitude = -159.82 m
Humidity = 42.26 %

Temperature = 18.20 *C
Pressure = 1032.58 hPa
Approx. Altitude = -159.73 m
Humidity = 42.25 %

running your i2cdetect code from post #6 I get

i2cdetect example

Scanning address range 0x03-0x77

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --

I assume the OLED is causing problems ???

Edit2: noted from Lolin32 OLED Pinout that the GPIOs are limied but GPIO25 and GPIO26 are available - connected

#include <Wire.h>
#include <i2cdetect.h>

#define I2C_SDA 26
#define I2C_SCL 25

void setup() {
  Wire.begin(I2C_SDA, I2C_SCL);
  //Wire.begin();
  Serial.begin(115200);
  Serial.println("i2cdetect example\n");
  Serial.print("Scanning address range 0x03-0x77\n\n");
  
}

void loop() {
  i2cdetect();
  delay(2000);
}

and a run displays

      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --

the I2Cdetect found the BME280 OK

Please post the make and model of the board you have.

I don't recall you mentioning that it has, or that you re using, an OLED display.

In any case, it is easy to find many pinout diagrams, not all tell the same thing.

Maybe take a picture of the front and back and post that, too, if you can't definitively identify the exact board you working with.

a7

PortB on a ESP32 won't do I2C, API Reference - ESP32 - — ESP-IDF Programming Guide latest documentation.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.