0

BME280 + Arduino UNO (sensor not found)
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

BME280 + Arduino UNO (sensor not found)

by enggang on Thu Jun 11, 2020 7:37 pm

Does anyone know what I've done wrong here? I've followed exactly what it says in the tutorial (link posted below) and the sensor's IC2 address can't be found and no temperature, humidity, or pressure is outputted. I've attempted to do the SPI wiring method as well and I cant get that working either.

SPI wiring instructions I followed:

Since this is a SPI-capable sensor, we can use 'software' SPI. To make wiring identical on all Arduinos, we'll begin with 'software' SPI. The following pins should be used:

Connect Vin to the power supply, 3V or 5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V
Connect GND to common power/data ground
Connect the SCK pin to Digital #13 but any pin can be used later
Connect the SDO pin to Digital #12 but any pin can be used later
Connect the SDI pin to Digital #11 but any pin can be used later
Connect the CS pin Digital #10 but any pin can be used later

With SPI wiring I used this code:

Code: Select all | TOGGLE FULL SIZE
/***************************************************************************
  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>


#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() {
    Serial.begin(9600);
    while(!Serial);    // time to get serial running
    Serial.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) {
        Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
        Serial.print("SensorID was: 0x"); Serial.println(bme.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);
    }
   
    Serial.println("-- Default Test --");
    delayTime = 1000;

    Serial.println();
}


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


void printValues() {
    Serial.print("Temperature = ");
    Serial.print(bme.readTemperature());
    Serial.println(" *C");

    Serial.print("Pressure = ");

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

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

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

    Serial.println();
}


The output I got in the serial monitor was:

19:29:00.233 -> BME280 test
19:29:00.233 -> Could not find a valid BME280 sensor, check wiring, address, sensor ID!
19:29:00.286 -> SensorID was: 0xFF
19:29:00.320 -> ID of 0xFF probably means a bad address, a BMP 180 or BMP 085
19:29:00.389 -> ID of 0x56-0x58 represents a BMP 280,
19:29:00.432 -> ID of 0x60 represents a BME 280.
19:29:00.488 -> ID of 0x61 represents a BME 680.

Tutorial I followed was in the description of the site I bought it from.

https://learn.adafruit.com/adafruit-bme280-humidity-barometric-pressure-temperature-sensor-breakout/arduino-test

When attempting the IC2 method I followed these instructions for the wiring:

Use this wiring if you want to connect via I2C interface

Connect Vin to the power supply, 3-5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V
Connect GND to common power/data ground
Connect the SCK pin to the I2C clock SCL pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A5, on a Mega it is also known as digital 21 and on a Leonardo/Micro, digital 3
Connect the SDI pin to the I2C data SDA pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A4, on a Mega it is also known as digital 20 and on a Leonardo/Micro, digital 2

I attempted to run the IC2 scanner:

Code: Select all | TOGGLE FULL SIZE
 // --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    https://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>


void setup()
{
  Wire.begin();

  Serial.begin(9600);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}


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

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the 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.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown 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);           // wait 5 seconds for next scan
}


Result from IC2 scanner:

19:13:09.400 -> I2C Scanner
19:13:09.400 -> Scanning...
19:13:09.400 -> No I2C devices found
19:13:09.400 ->
19:13:14.375 -> Scanning...
19:13:14.410 -> No I2C devices found
19:13:14.410 ->
19:13:19.405 -> Scanning...
19:13:19.405 -> No I2C devices found
19:13:19.405 ->
19:13:24.414 -> Scanning...
19:13:24.449 -> No I2C devices found

Wiring diagram (followed tutorial at link posted above) - see picture attached:

IMG_2617.jpg
IMG_2617.jpg (915.31 KiB) Viewed 298 times
Last edited by enggang on Thu Jun 11, 2020 7:43 pm, edited 1 time in total.

enggang
 
Posts: 3
Joined: Thu Jun 11, 2020 7:23 pm

Re: BME280 + Arduino UNO (sensor not found)

by adafruit_support_bill on Thu Jun 11, 2020 7:40 pm

Please post some photos showing your soldering and connections.

adafruit_support_bill
 
Posts: 81286
Joined: Sat Feb 07, 2009 10:11 am

Re: BME280 + Arduino UNO (sensor not found)

by enggang on Thu Jun 11, 2020 7:51 pm

IC2 Wiring:

IMG_2617.jpg
IMG_2617.jpg (915.31 KiB) Viewed 297 times

enggang
 
Posts: 3
Joined: Thu Jun 11, 2020 7:23 pm

Re: BME280 + Arduino UNO (sensor not found)

by adafruit_support_bill on Thu Jun 11, 2020 8:11 pm

Can you post a close-up view that clearly shows your soldering on the headers to the sensor board?

adafruit_support_bill
 
Posts: 81286
Joined: Sat Feb 07, 2009 10:11 am

Re: BME280 + Arduino UNO (sensor not found)

by enggang on Thu Jun 11, 2020 8:30 pm

So, I haven't solder anything. I simple put the metal things it came with through the hoops of the sensor and stuck it into the breadboard. Would that not give proper connectivity between the breadboard and the sensors? If you are sure that would be the issue whats the proper way to solder them together.




IMG_2622.jpg
IMG_2622.jpg (648.84 KiB) Viewed 295 times

enggang
 
Posts: 3
Joined: Thu Jun 11, 2020 7:23 pm

Re: BME280 + Arduino UNO (sensor not found)

by adafruit_support_bill on Thu Jun 11, 2020 8:38 pm

Solder is required for reliable connections. See the guide for assembly instructions:
https://learn.adafruit.com/adafruit-bme ... t/assembly

If you are new to soldering, you might want to start by reading through our soldering guide here:
https://learn.adafruit.com/adafruit-gui ... -soldering

adafruit_support_bill
 
Posts: 81286
Joined: Sat Feb 07, 2009 10:11 am

Re: BME280 + Arduino UNO (sensor not found)

by dolf on Thu Apr 29, 2021 11:15 pm

Hi,

Seems like enggang solved their problem with soldering. I have the same BME problem on a Metro, but my header is soldered in. All of my jumper continuities are good from board solder to board solder. What's next?

dolf
 
Posts: 3
Joined: Sun Sep 01, 2013 8:38 pm

Re: BME280 + Arduino UNO (sensor not found)

by adafruit_support_bill on Fri Apr 30, 2021 5:41 am

@dolf

Please post some photos showing all of your soldering and connections.

adafruit_support_bill
 
Posts: 81286
Joined: Sat Feb 07, 2009 10:11 am

Re: BME280 + Arduino UNO (sensor not found)

by dolf on Fri Apr 30, 2021 3:35 pm

I have tried two of these. The one connected and the one in the bottom right of the breadboard.
PXL_20210430_192324670.jpg
BME_280s soldered
PXL_20210430_192324670.jpg (946.36 KiB) Viewed 213 times

dolf
 
Posts: 3
Joined: Sun Sep 01, 2013 8:38 pm

Re: BME280 + Arduino UNO (sensor not found)

by adafruit_support_bill on Sat May 01, 2021 5:45 am

The soldering looks good. But we need to see where all the wires connect also.

adafruit_support_bill
 
Posts: 81286
Joined: Sat Feb 07, 2009 10:11 am

Re: BME280 + Arduino UNO (sensor not found)

by dolf on Mon May 03, 2021 2:47 pm

I figured it out. I had not correctly commented/uncommented the I2C and SPI lines.

This is how they are received in the library.

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

When using SPI, as I am, one needs to modify these to:

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


Adafruit,

I recommend you make the "SPI software" version the default because it is most likely the version that a beginner will use, or have all three commented out to clearly highlight that one must be chosen.


Plus, I have been unable to find an explanation of the difference between "SPI software" and "SPI hardware". Can you offer a brief explanation here?

Cheers

dolf
 
Posts: 3
Joined: Sun Sep 01, 2013 8:38 pm

Re: BME280 + Arduino UNO (sensor not found)

by adafruit_support_bill on Mon May 03, 2021 3:07 pm

I2c is the most popular option for these sensors. i2 is a well established standard and the wiring is simpler than for SPI.

The difference between hardware and software SPI is native hardware support for the protocol. Software or 'Bit Bang' implementations of SPI are generally slower and have more CPU overhead than hardware implementations. However, SPI does not have a formal standard and not all hardware implementations play well with others, so sometimes a bit-bang solution is necessary.

adafruit_support_bill
 
Posts: 81286
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.