BME280 to Datalogging shield

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
mromero
 
Posts: 94
Joined: Fri Mar 18, 2016 12:10 pm

BME280 to Datalogging shield

Post by mromero »

I am connecting a BME280 to the Metro (uno board) and datalogguing shield per demo sketch

Open up File->Examples->Adafruit_BME280->bmp280test . I used the software SPI connection.

my question is the example for the datalogger sketch example for the logger shield " Light&TempLogger" is using analog inputs for the e sensos while the "BME280test" is using digital pins 10 thru 13. Do we still follow the example but just replace the analogue pins for the digital ones use by the BME280 test?

Also if anyone could help me format the output its in comma delimeted for time,T, RH, pressure that would be of great help. I have checked the forums but still dong get it.

Code: Select all

 
//--------------------------------- variables
#include "SD.h"        // for datalogger sd card
#include "RTClib.h"    // real time clock in datalogger
#include <Wire.h>     // for i2c communication
#include <SPI.h>     // for SPI communication
#include <Adafruit_Sensor.h>   // adafruit sensor library
#include <Adafruit_BME280.h>  //library to run T,%RH,atm pressure sensor

#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 connection

unsigned long delayTime;
//-------------------------------End  variables

//------------------------------open void setup--------------------------------------------------
void setup() {

  //------------ BME280
    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)
    
    // error if you cant find sensor
    
    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();
  //-----------BME280 END
    
}//---------------------close void set up-------------------------------------------------------


//----------------------open void loop----------------------------------------------------------

void loop() { 
  
//---------for BME280 use
    printValues();
    delay(delayTime);
//---------close BME280    


}//---------------------close void loop-------------------------------------------------------------



//----------------------Subroutines----------------------------------------------------------------

//----------------Printe BME output

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();
} //-------------End BME output  

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: BME280 to Datalogging shield

Post by adafruit_support_mike »

The code to use the sensors on the Datalogging Shield won't work for the BME280. They use completely different interfaces.

If you want to combine the BME280 with the Datalogging Shield, you'll need to combine the code from the example sketches.

Just cutting and pasting code won't work though. Read the example code to understand how to use each sensor, and how to use the information you get from each sensor.

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

Return to “Arduino Shields from Adafruit”