Problems to connect M0 Adalogger with BME 280 Sensor

Adafruit's tiny microcontroller platform. Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Dennis_Rchtr
 
Posts: 6
Joined: Tue Jun 07, 2022 5:56 am

Problems to connect M0 Adalogger with BME 280 Sensor

Post by Dennis_Rchtr »

Hello, I want to connect my Feather M0 Adalogger with a BME 280 Sensor. So I connect:
Vcc: to 3.3 V
GND: to GND
SCL: to SCL (for I2C), SCK (for SPI)
SDA: to SDA (for I2C), MOSI (for SPI)
CS: I dont find the correct PIN (for SPI) (I tryed D0, D9)
SDO: to MISO (for SPI)

I started the Example Sketch from Arduino: "bme280test"

Code: Select all

/***************************************************************************
  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 11
#define BME_MISO 12
#define BME_MOSI 10
#define BME_CS 7
*/
#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();
}
result in serial monitor:

with I2C: "12:03:18.141 -> BME280 test"

with SPI: "12:10:29.240 -> BME280 test
12:10:29.240 -> Could not find a valid BME280 sensor, check wiring, address, sensor ID!
12:10:29.240 -> SensorID was: 0xFF
12:10:29.240 -> ID of 0xFF probably means a bad address, a BMP 180 or BMP 085
12:10:29.240 -> ID of 0x56-0x58 represents a BMP 280,
12:10:29.240 -> ID of 0x60 represents a BME 280.
12:10:29.240 -> ID of 0x61 represents a BME 680."

I canged a part of the sketch to:

Code: Select all

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

#define BME_SCK SCK  //Pin name
#define BME_MISO MISO//Pin name
#define BME_MOSI MOSI//Pin name
#define BME_CS 9     //unknown the right Pin

#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();
} 
Can someone help me pls? Do you need more pictures ?
Attachments
WhatsApp Image 2022-06-07 at 12.22.12.jpeg
WhatsApp Image 2022-06-07 at 12.22.12.jpeg (504.39 KiB) Viewed 196 times

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Problems to connect M0 Adalogger with BME 280 Sensor

Post by adafruit_support_bill »

The main problem is likely because none of your connections are soldered. Sticking the ends of the jumpers through the solder-holes does not create a reliable electrical connection.

You need to either solder the headers to your Feather before plugging it into the breadboard, or solder the jumper wires directly.

User avatar
Dennis_Rchtr
 
Posts: 6
Joined: Tue Jun 07, 2022 5:56 am

Re: Problems to connect M0 Adalogger with BME 280 Sensor

Post by Dennis_Rchtr »

Thanks for your fast answer.
I tryed the same construction on a Arduino Mega. There were no problems.
But I´m unsure which pins I need to use for the M0 Adafruit.

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Problems to connect M0 Adalogger with BME 280 Sensor

Post by adafruit_support_bill »

I tryed the same construction on a Arduino Mega. There were no problems.
The Mega has headers soldered to it with spring contacts inside for reliable connections. Simple solder holes as on the Adalogger are not the same at all.
But I´m unsure which pins I need to use for the M0 Adafruit.
The necessary pins are labeled on the board: GND, 3.3v, SDA and SCL

User avatar
Dennis_Rchtr
 
Posts: 6
Joined: Tue Jun 07, 2022 5:56 am

Re: Problems to connect M0 Adalogger with BME 280 Sensor

Post by Dennis_Rchtr »

I tryed to connect via I2C, so I use the 3.3v, GND, SCL and SDA PINs but it dosen´t connect.
So I try connect via SPI: use the SCK, MOSI, MISO and D0 (RX) PINs, it works.

But why I can´t connect via I2C?
here the scatch for SPI

Code: Select all

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

#define BME_SCK SCK
#define BME_MISO MISO
#define BME_MOSI MOSI
#define BME_CS 0

#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();
}

I tryed to change the status = bme.begin(): in ...begin(0x76) ....begin(0x77) ... nothing change.

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Problems to connect M0 Adalogger with BME 280 Sensor

Post by adafruit_support_bill »

But why I can´t connect via I2C?
Please post a photo showing your soldering and connections.

User avatar
Dennis_Rchtr
 
Posts: 6
Joined: Tue Jun 07, 2022 5:56 am

Re: Problems to connect M0 Adalogger with BME 280 Sensor

Post by Dennis_Rchtr »

So I Connect the black wire to the SCL and the Yellow to the SDA, the other to 3.3v and GND.
The sketch changed to:

Code: Select all

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
/*
#define BME_SCK SCK
#define BME_MISO MISO
#define BME_MOSI MOSI
#define BME_CS 0
*/
#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 = 5000;

    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();
}
Attachments
WhatsApp Image 2022-06-08 at 13.17.15.jpeg
WhatsApp Image 2022-06-08 at 13.17.15.jpeg (412.76 KiB) Viewed 169 times

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Problems to connect M0 Adalogger with BME 280 Sensor

Post by adafruit_support_bill »

That all looks OK. And your SPI wiring sounds correct also.

Check to make sure that the sensor board is getting power and ground. Some breadboards have a gap in the middle of the power and ground rails.

If all that checks out, the problem is likely in your sensor.

User avatar
Dennis_Rchtr
 
Posts: 6
Joined: Tue Jun 07, 2022 5:56 am

Re: Problems to connect M0 Adalogger with BME 280 Sensor

Post by Dennis_Rchtr »

Ok thanks. I checked all the thinks. It is possible that the Sensor only use SPI ?!

Now I try to safe the data on the SD-Card.

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Problems to connect M0 Adalogger with BME 280 Sensor

Post by adafruit_support_bill »

It is possible that the Sensor only use SPI ?!
The chip requires a pullup on the CS pin to enable i2c communication. Our BME280 boards have a 10K pullup resistor. It is possible that the board you are using does not.

User avatar
Dennis_Rchtr
 
Posts: 6
Joined: Tue Jun 07, 2022 5:56 am

Re: Problems to connect M0 Adalogger with BME 280 Sensor

Post by Dennis_Rchtr »

adafruit_support_bill wrote:
It is possible that the Sensor only use SPI ?!
The chip requires a pullup on the CS pin to enable i2c communication. Our BME280 boards have a 10K pullup resistor. It is possible that the board you are using does not.
When I use an extra 10K Pullup resistor, how do I have to connect this, with which pins ?

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Problems to connect M0 Adalogger with BME 280 Sensor

Post by adafruit_support_bill »

you would need to connect the pullup between CS and VCC

Locked
Please be positive and constructive with your questions and comments.

Return to “Trinket ATTiny, Trinket M0”