Arduino, BMP280 and SD card reader

Hello all - can someone suggest the code for running a BMP280 on Arduino, that writes the serial data to an SD card? I have both the RTC data logging shield and LB SD Card read/writer to use. Goal is to be able to graph the SD card data in excel from the BMP sensor. TIA

Have you tried: https://github.com/adafruit/Adafruit_BMP280_Library and https://gist.github.com/schappim/e731b360f9d26195e9c00644e9ae6225 ?

Cheers,

Marcus

Here is my code. Detects the SD Card - isn’t detecting the BMP sensor…

/*

  • SD card attached to SPI bus as follows:
    ** MOSI - pin 11
    ** MISO - pin 12
    ** CLK - pin 13
    ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)

*/

#include <SPI.h>
#include <SD.h>
#include <Adafruit_BMP280.h>
Adafruit_BMP280 bmp; // I2C Interface
File myFile;

float temp;
float pres;
float alt;

void setup() {
Serial.begin(9600);

while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

Serial.print(“Initializing SD card…”);

if (!SD.begin(4)) {
Serial.println(“initialization failed!”);
while (1);
}
Serial.println(“initialization done.”);

myFile = SD.open(“datalog.csv”, FILE_WRITE);

Serial.println(F(“BMP280 test”));

if (!bmp.begin()) {
Serial.println(F(“Could not find a valid BMP280 sensor, check wiring!”));
while (1);
}

/* Default settings from datasheet. /
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /
Operating Mode. /
Adafruit_BMP280::SAMPLING_X2, /
Temp. oversampling /
Adafruit_BMP280::SAMPLING_X16, /
Pressure oversampling /
Adafruit_BMP280::FILTER_X16, /
Filtering. /
Adafruit_BMP280::STANDBY_MS_500); /
Standby time. */
}

void loop() {

temp=bmp.readTemperature();
pres=bmp.readPressure()/100;
alt=bmp.readAltitude(1030.25);
Serial.print(F("Temperature = "));
Serial.print(temp);
Serial.println(" *C");

Serial.print(F("Pressure = "));
Serial.print(pres); //displaying the Pressure in hPa, you can change the unit
Serial.println(" hPa");

Serial.print(F("Approx altitude = "));
Serial.print(alt); //The "1019.66" is the pressure(hPa) at sea level in day in your region
Serial.println(" m");                    //If you don't know it, modify it until you get your current altitude

// if the file opened okay, write to it:
if (myFile) {
Serial.print(“Logging data…”);
myFile.print(temp);
myFile.print(",");
myFile.print(pres);
myFile.print(",");
myFile.print(alt);
myFile.println();
// close the file:
myFile.close();
} else {
// if the file didn’t open, print an error:
Serial.println(“error opening test.txt”);
}

Serial.println();
delay(2000);

}