UNO Q 4GB : Issues with I2C BME280 detect!

Hi,

I’m looking to connect a BME280 to the UNO Q but seems that the sensor isn’t detected by the board . I’ve installed the i2cdetect.h library ( I’m working with the IDE 2.3.7) and tried to use the i2cscan example to check if was recognised . The sensor is connected to SDL and SDA pin that should be the right one when is used wire.begin() otherwise wire1.begin() address the qwiic connector. I’ve modified the sketch because with the UNO Q seems that the Serial.print dosen’t work as usual so must be used Monitor.print. this is the code

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

void setup() {
Wire.begin();
Monitor.begin();
Monitor.print("i2cdetect example");
}

void loop() {
i2cdetect();  // default range from 0x03 to 0x77
delay(2000);
Monitor.println("Scanning address range 0x03-0x77");
}

At the end the sensor isn’t detected , I've moved the SLC/SDA on A4 and A5 , and the serial monitor show this instead than place the new line at the end of message in the loop.

20:05:23.727 -> Scanning address range 0x03-0x77Scanning address range 0x03-0x77Scanning address range 0x03-0x77Scanning address range 0x03-0x77

So at this point I'm not sure if I2cdetect.h is compatible with UNO Q and why the new line on Monitor.print isn't recognised .

Any suggestion?

P.S. I forgot to say that to see the output from the serial monitor I must disable the line i2cdetect() !

Are you using the following breakout board for BME280 (Fig-1)?



Figure-1:

Yes!

1. I have just now tested this breakout board usig my UNO Q (2 GB/16 GB).

2.
Connect 3.3V at VIN-pin
SCL/SDA wit SCL/SDA pins
GND with GND pin

3. Upload the following sketch. Check that correct readings appear on Monitor Console.

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

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme;  // I2C interface

void setup() {
  Bridge.begin();
  Monitor.begin();

  Monitor.println("BME280 test");

  // Try address 0x76 first
  if (!bme.begin(0x76)) {
    Monitor.println("Could not find BME280 at 0x76, trying 0x77...");
    if (!bme.begin(0x77)) {
      Monitor.println("BME280 not found. Check wiring!");
      while (1);
    }
  }

  Monitor.println("BME280 initialized successfully");
}

void loop() {
  Monitor.print("Temperature = ");
  Monitor.print(bme.readTemperature());
  Monitor.println(" °C");

  Monitor.print("Humidity = ");
  Monitor.print(bme.readHumidity());
  Monitor.println(" %");

  Monitor.print("Pressure = ");
  Monitor.print(bme.readPressure() / 100.0F);
  Monitor.println(" hPa");

  Monitor.print("Approx. Altitude = ");
  Monitor.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
  Monitor.println(" m");

  Monitor.println("-----------------------------");
  delay(2000);
}

4. Output:

-----------------------------
Temperature = 26.98 °C
Humidity = 62.20 %
Pressure = 1012.16 hPa
Approx. Altitude = 9.04 m
-----------------------------

5. To get an idea on the distincton of Serial and Monitor objects, you may look at the diagram of Fig-1. This diagram will also help to know how the sketch is being uploaded in the flash memory of the target MCU (STM32U585) via the MPU.


Figure-1:

Hi @GolamMostafa ,
your code works fine !

In my previous tentative I've tryed to use the below code that comes from examples bme280test.ino from the library ADAFRUIT BME280 from which I think derives your code.


/***************************************************************************
  This is a library for the BME280 humidity, temperature & pressure sensor

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

  These sensors use I2C or SPI to communicate, 2 or 4 pins are required
  to interface. The device's I2C address is either 0x76 or 0x77.

  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
  See the LICENSE file for details.
 ***************************************************************************/

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include<Arduino_RouterBridge.h>
#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI

unsigned long delayTime;

void setup() {
    Monitor.begin();
    while(!Monitor);    // time to get Monitor running
    Monitor.println(F("BME280 test"));

    unsigned status;
    
    // default settings
    status = bme.begin();  
    // You can also pass in a Wire library object like &Wire2
    // status = bme.begin(0x76, &Wire2)
    if (!status) {
        Monitor.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
        Monitor.print("SensorID was: 0x"); Monitor.println(bme.sensorID(),16);
        Monitor.print("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
        Monitor.print("   ID of 0x56-0x58 represents a BMP 280,\n");
        Monitor.print("        ID of 0x60 represents a BME 280.\n");
        Monitor.print("        ID of 0x61 represents a BME 680.\n");
        while (1) delay(10);
    }
    
    Monitor.println("-- Default Test --");
    delayTime = 1000;

    Monitor.println();
}


void loop() { 
    printValues();
    delay(delayTime);
}


void printValues() {
    Monitor.print("Temperature = ");
    Monitor.print(bme.readTemperature());
    Monitor.println(" °C");

    Monitor.print("Pressure = ");

    Monitor.print(bme.readPressure() / 100.0F);
    Monitor.println(" hPa");

    Monitor.print("Approx. Altitude = ");
    Monitor.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
    Monitor.println(" m");

    Monitor.print("Humidity = ");
    Monitor.print(bme.readHumidity());
    Monitor.println(" %");

    Monitor.println();
}

but the output is the follow so now I'll try to understende the differences :grinning_face::

Thanks again !