BME280 Sensor

Generic BME280 Sensors

This section deals with two generic variants of the BME280 sensor used to measure temperature, humidity and pressure.

While the module on the left in the above photo is often identified as a 5V module and the one on the right a 3.3V module both, in my experience, work just fine with a 3.3V supply. The practical difference is that the one on the left has only an I2C interface while the one on the right has both I2C and SPI interfaces.

When using the I2C interface, both modules are configured to use I2C address 0x76 by default. Solder jumpers are provided to enable the configuration of the alternate 0x77 address if required. In the image below, if you look closely you will see that the two pads on the left are connected. To change the sensor I2C address to 0x77, the link between these two pads needs to be cut and the two rightmost pads bridged. Other BME modules generally include a similar arrangement for I2C address selection.

BME280

I2C Address Jumpers

Application

BME280 atmospheric sensor modules were used in a number of Nodes that I still use to primarily report temperature data. At that level they're now probably a bit of overkill, since most of my base boards now include a DS18B20 temperature sensor. But they are one of the simplest I2C modules I have and as such are a good tool for testing the operation of the I2C bus in new configurations.

Configuration

Hardware

CubeCell / BME280 Hardware Configuration CubeCell / BME280 Hardware Configuration

CubeCell / BME280 I2C Hardware Configuration CubeCell / BME280 I2C Hardware Configuration

Example BME280 I2C Electrical Circuits
Pin Configurations
CubeCell WiFi LoRa 32 (V3) BME280
Vext Vext VCC
GND GND GND
SCL GPIO20 SCL
SDA GPIO19 SDA

CubeCell / BME280 SPI Hardware Configuration CubeCell / BME280 SPI Hardware Configuration

Example BME280 SPI Electrical Circuits
Pin Configurations
CubeCell WiFi LoRa 32 (V3) BME280
Vext Vext VCC
GND GND GND
SCK GPIO33 SCK
MISO GPIO34 SDO
MOSI GPIO7 SDI
GPIO1 GPIO6 CS

Software


BME280 I2C Test Sketch
/* Basic BME280 test for ESP MCUs
 *
 * Function:
 * Read BME280 sensor and report response
 * 
 * Rev 1.0  23 Nov 2022
 * Digital Concepts
 * digitalconcepts.net.au
 *
 */

#include "Adafruit_BME280.h"  // BME280 class & methods
#include "Adafruit_Sensor.h"  // BME280 sensor support methods
#include "Wire.h"             // Need this to define second I2C bus

#include "WiFiLoRa32V3Pins.h"

#define useVext false   // To test Vext/Vint switch

// BME280 Settings
const int I2C_BME_Address = 0x76;

// Define BME280 sensor
Adafruit_BME280 bme280;             // Defaults (I2C_BME_Address = 0x77) set within Adafruit libraries

uint16_t humidity = 0;
uint16_t pressure = 0;
int16_t temperature = 0;

const float LSB = 0.02761647; // per manual calibration (when using int in 1/10mm)

const int reportInterval = 5000;     // Report values every 10000 milliseconds (10 seconds)

int messageCounter = 0;

void setup() {
  pinMode(Builtin_LED,OUTPUT);     // Will use LED to signal packet transmission
  digitalWrite(Builtin_LED,LOW);  // Turn it on...
  
  Serial.begin(115200);
  while (!Serial);        // If just the the basic function, must connect to a computer
    delay(500);
  Serial.println("[setup] I2C BME Test");

  pinMode(Vext_Ctrl,OUTPUT);    // Power supply to connected devices
  if ( useVext ) {
    digitalWrite(Vext_Ctrl,LOW);  // Turn it on
    Serial.println("[setup] Vext ON");
  } else {
    digitalWrite(Vext_Ctrl,HIGH);  // Turn it on
    Serial.println("[setup] Vext OFF, test will require alternate power source");
  }

// Initialise the BME280 sensor
  Serial.println("[setup] Initialise BME280 sensor");
  Wire.begin(SDA,SCL);
  if (bme280.begin(I2C_BME_Address)) {
    Serial.println("[setup] BME280 sensor initialisation complete");
  } else {
    Serial.println("[setup] Could not find a valid BME280 sensor, check wiring!");
//    while (true);
  }
  Serial.println();

  Serial.println("[setup] Set-up Complete");

  //  Let everything settle down before continuing
  delay(500);
}

void loop() {
  readSensor();
  Serial.println("[loop] Delay...");
  delay(reportInterval);
}

void readSensor() {
  temperature = (int) (10*bme280.readTemperature());
  pressure = (int) (bme280.readPressure() / 91.79F);
  humidity = (int) (bme280.readHumidity());

  Serial.println("");
  Serial.print("[readSensor] Temperature: ");
  Serial.println((float) temperature/10, 1);
  Serial.print("[readSensor] Pressure: ");
  Serial.println(pressure);
  Serial.print("[readSensor] Humidity: ");
  Serial.println(humidity);
}

BME280 SPI Test Sketch

Further details pending

03-09-2026