WiFi LoRa 32 (V3) and BMP280 Sensor

I’m trying to use BMP280 sensor with the adafruit library and i can’t achieve it.
If i use the I2C Wirescan example adding Wire.begin(41, 42) :
#include “Wire.h”

void setup() {
Serial.begin(115200);
Wire.begin(41, 42);
}

void loop() {
byte error, address;
int nDevices = 0;

delay(5000);

Serial.println(“Scanning for I2C devices …”);
for(address = 0x01; address < 0x7f; address++){
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0){
Serial.printf(“I2C device found at address 0x%02X\n”, address);
nDevices++;
} else if(error != 2){
Serial.printf(“Error %d at address 0x%02X\n”, error, address);
}
}
if (nDevices == 0){
Serial.println(“No I2C devices found”);
}
}

I obtain :

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x9 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x43c
load:0x403c9700,len:0xbec
load:0x403cc700,len:0x2a3c
SHA-256 comparison failed:
Calculated: dcde8d8a4817d9bf5d5d69a7247667264e4e10ac7493514868b61f5aa6146539
Expected: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Attempting to boot anyway…
entry 0x403c98d8
Scanning for I2C devices …
I2C device found at address 0x61
I2C device found at address 0x76

Which is correct because i have connected a scd30 and a BMP280 sensor

Trying to use the bmp280test example i obtain (adding Wire.begin(41, 42) or not ):
/***************************************************************************
This is a library for the BMP280 humidity, temperature & pressure sensor

Designed specifically to work with the Adafruit BMP280 Breakout
----> http://www.adafruit.com/products/2651

These sensors use I2C or SPI to communicate, 2 or 4 pins are required
to interface.

Adafruit invests time and resources providing this open source code,
please support Adafruit andopen-source hardware by purchasing products
from Adafruit!

Written by Limor Fried & Kevin Townsend for Adafruit Industries.
BSD license, all text above must be included in any redistribution
***************************************************************************/

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>

#define BMP_SCK (13)
#define BMP_MISO (12)
#define BMP_MOSI (11)
#define BMP_CS (10)

Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
//Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);

void setup() {
Serial.begin(9600);
while ( !Serial ) delay(100); // wait for native usb
Serial.println(F(“BMP280 test”));
unsigned status;
//status = bmp.begin(BMP280_ADDRESS_ALT, BMP280_CHIPID);
Wire.begin(41, 42);
status = bmp.begin();
if (!status) {
Serial.println(F(“Could not find a valid BMP280 sensor, check wiring or "
“try a different address!”));
Serial.print(“SensorID was: 0x”); Serial.println(bmp.sensorID(),16);
Serial.print(” ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n");
Serial.print(" ID of 0x60 represents a BME 280.\n");
Serial.print(" ID of 0x61 represents a BME 680.\n");
while (1) delay(10);
}

/* Default settings from datasheet. /
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /
Operating Mode. /
Adafruit_BMP280::SAMPLING_X2, /
Temp. oversampling /
Adafruit_BMP280::SAMPLING_X16, /
Pressure oversampling /
Adafruit_BMP280::FILTER_X16, /
Filtering. /
Adafruit_BMP280::STANDBY_MS_500); /
Standby time. */
}

void loop() {
Serial.print(F(“Temperature = “));
Serial.print(bmp.readTemperature());
Serial.println(” *C”);

Serial.print(F("Pressure = "));
Serial.print(bmp.readPressure());
Serial.println(" Pa");

Serial.print(F("Approx altitude = "));
Serial.print(bmp.readAltitude(1013.25)); /* Adjusted to local forecast! */
Serial.println(" m");

Serial.println();
delay(2000);

}

Leads to :

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x9 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x43c
load:0x403c9700,len:0xbec
load:0x403cc700,len:0x2a3c
SHA-256 comparison failed:
Calculated: dcde8d8a4817d9bf5d5d69a7247667264e4e10ac7493514868b61f5aa6146539
Expected: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Attempting to boot anyway…
entry 0x403c98d8

If i try the same with the SCD30 :
// Basic demo for readings from Adafruit SCD30
#include <Adafruit_SCD30.h>

Adafruit_SCD30 scd30;

void setup(void) {
Serial.begin(115200);
while (!Serial) delay(10); // will pause Zero, Leonardo, etc until serial console opens

Serial.println(“Adafruit SCD30 test!”);
Wire.begin(41, 42);
// Try to initialize!
if (!scd30.begin()) {
Serial.println(“Failed to find SCD30 chip”);
while (1) { delay(10); }
}
Serial.println(“SCD30 Found!”);

// if (!scd30.setMeasurementInterval(10)){
// Serial.println(“Failed to set measurement interval”);
// while(1){ delay(10);}
// }
Serial.print(“Measurement Interval: “);
Serial.print(scd30.getMeasurementInterval());
Serial.println(” seconds”);
}

void loop() {
if (scd30.dataReady()){
Serial.println(“Data available!”);

if (!scd30.read()){ Serial.println(“Error reading sensor data”); return; }

Serial.print(“Temperature: “);
Serial.print(scd30.temperature);
Serial.println(” degrees C”);

Serial.print(“Relative Humidity: “);
Serial.print(scd30.relative_humidity);
Serial.println(” %”);

Serial.print(“CO2: “);
Serial.print(scd30.CO2, 3);
Serial.println(” ppm”);
Serial.println("");
} else {
//Serial.println(“No data”);
}

delay(100);
}

It works fine :
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x9 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x43c
load:0x403c9700,len:0xbec
load:0x403cc700,len:0x2a3c
SHA-256 comparison failed:
Calculated: dcde8d8a4817d9bf5d5d69a7247667264e4e10ac7493514868b61f5aa6146539
Expected: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Attempting to boot anyway…
entry 0x403c98d8
Adafruit SCD30 test!
SCD30 Found!
Measurement Interval: 2 seconds
Data available!
Temperature: 26.42 degrees C
Relative Humidity: 52.42 %
CO2: 762.479 ppm

So i can’t figure out why it does not work correctly with BMP280…

You probably need to tell the library to use “Wire” as the connection for your BMP280

Try changing:
Adafruit_BMP280 bmp;
to:
Adafruit_BMP280 bmp(&Wire);

By the way, you can check in the library, which options are available:


Adafruit_BMP280(TwoWire *theWire = &Wire);
Adafruit_BMP280(int8_t cspin, SPIClass *theSPI = &SPI);
Adafruit_BMP280(int8_t cspin, int8_t mosipin, int8_t misopin, int8_t sckpin);

Hope this helps. Have a nice day

Thanks
Have a nice day

I found this BME280 works. Sparkfun BME280 script the Basic Reading.

/*

  Get basic environmental readings from the BME280

  By: Nathan Seidle

  SparkFun Electronics

  Date: March 9th, 2018

  License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).

  Feel like supporting our work? Buy a board from SparkFun!

  https://www.sparkfun.com/products/14348 - Qwiic Combo Board

  https://www.sparkfun.com/products/13676 - BME280 Breakout Board

 

  This example shows how to read humidity, pressure, and current temperature from the BME280 over I2C.

  Hardware connections:

  BME280 -> Arduino

  GND -> GND

  3.3 -> 3.3

  SDA -> A4

  SCL -> A5

*/

#include <Wire.h>

#include "SparkFunBME280.h"

BME280 mySensor;

void setup()

{

  Serial.begin(115200);

  Serial.println("Reading basic values from BME280");

  Wire.begin();

  if (mySensor.beginI2C() == false) //Begin communication over I2C

  {

    Serial.println("The sensor did not respond. Please check wiring.");

    while(1); //Freeze

  }

}

void loop()

{

  Serial.print("Humidity: ");

  Serial.print(mySensor.readFloatHumidity(), 0);

  Serial.print(" Pressure: ");

  Serial.print(mySensor.readFloatPressure(), 0);

  Serial.print(" Alt: ");

  //Serial.print(mySensor.readFloatAltitudeMeters(), 1);

  Serial.print(mySensor.readFloatAltitudeFeet(), 1);

  Serial.print(" Temp: ");

  //Serial.print(mySensor.readTempC(), 2);

  Serial.print(mySensor.readTempF(), 2);

  Serial.println();

  delay(50);

}

Thank you.

I had to change the SDA and SCL pins to 19 and 20, and the I2C address to 0x76 (in the library).
But I can confirm it works on WSL V3.