BME280 values won't show up in logfile

wvmarle:
As test: replace all the logfile.print() statements by Serial.print() statements to see what you really try to print to your log file. Make sure that matches your expectations. Makes debugging a lot easier.

The easiest way to do this is not by editing all those lines in your code but by adding a #define statement and uncommenting some other lines...

#define Logfile Serial

It also tells you whether you're running the latest version of your sketch which, based on earlier comments, is also anything but certain.

I just did that. I don't get any errors, but the serial monitor shows nothing at all. Why is that?

Here is the modified code to display the values on the serial monitor instead of the logfile:

//NJarpa
//Arduino Data Logger with 2 DS18B20 and sample rate control(every 1 min)
//You must have a datalogger shield(RTC and SD card) mounted
// DS18B20 Pinout (Wires)
//Black   = Ground
//Blue    = Signal (Pin 2):  (Normal power mode with 3.3K to 4.7K resistor to +5 or 3.3 )
//Red     = +5 or +3.3 V

#include <Wire.h>                //Libraries we need
#include "RTClib.h"
#include <OneWire.h>           
#include <DallasTemperature.h>
#include <SPI.h>
#include <SD.h>

#include <dht.h> //////////A
dht DHT; //////////A

#include <math.h>  //////////C

#include <Adafruit_Sensor.h> //////////D
#include <Adafruit_BME280.h> //////////D

#define Logfile Serial

#define ONE_WIRE_BUS_PIN 2              // The pin that we are using for sensors

#define DHT21A_PIN 3 //////////A
#define DHT21B_PIN 5 //////////B

int BH1750address = 0x23; //setting i2c address //////////C

byte buff[2]; //////////C

Adafruit_BME280 bme; //////////D
unsigned long delayTime; //////////D


//Variables //////////A
float humA;  //Stores humidity value //////////A
float tempA; //Stores temperature value //////////A

//Variables //////////B
float humB;  //Stores humidity value //////////B
float tempB; //Stores temperature value //////////B

OneWire oneWire(ONE_WIRE_BUS_PIN);     // Setup oneWire
DallasTemperature sensors(&oneWire);   //  oneWire to Dallas Temperature.
RTC_DS1307 RTC;                        // define the Real Time Clock object

const int chipSelect = 4;              //CS pin of your data logger shield.Maybe not yours!!
///File Logfile;                          //Name of the file

// Assign the addresses of your  temp sensors.
//Every sensor has it own address.You must use 1 wire adress finder.

DeviceAddress Probe01 = { 0x28, 0x7E, 0xA5, 0x77, 0x91, 0x08, 0x02, 0x13 }; //inox2
DeviceAddress Probe02 = { 0x28, 0xAA, 0x21, 0x9E, 0x13, 0x13, 0x02, 0xE7 }; //Inox1
DeviceAddress Probe03 = { 0x28, 0xAA, 0x5E, 0xA8, 0x13, 0x13, 0x02, 0xA4 };
DeviceAddress Probe04 = { 0x28, 0xAA, 0xA9, 0xA5, 0x13, 0x13, 0x02, 0xCE };
//DeviceAddress Probe05 = { 0x28, 0x7E, 0xA5, 0x77, 0x91, 0x08, 0x02, 0x13 }; //uncomment for further DS18B20 sensor

int BH1750_Read(int address) { //////////C
        int i=0; //////////C
        Wire.beginTransmission(address); //////////C
        Wire.requestFrom(address, 2); //////////C
        while(Wire.available()) { //////////C
                buff[i] = Wire.read();  // receive one byte //////////C
                i++; //////////C
        } //////////C
        Wire.endTransmission();  //////////C
        return i; //////////C
} //////////C

void BH1750_Init(int address) { //////////C
        Wire.beginTransmission(address); //////////C
        Wire.write(0x10);//1lx reolution 120ms //////////C
        Wire.endTransmission(); //////////C
} //////////C


void setup()
{
Serial.begin(9600); /////serial monitor
  //pinMode(10 , OUTPUT);           //For some data logger shields.Uncomment if you need
  
SD.begin(chipSelect);            //Initialize the libraries
Wire.begin();
RTC.begin();
sensors.begin();    
  
  // set the resolution to 9 bit (Can be 9 to 12 bits .. lower is faster)
  sensors.setResolution(Probe01, 9);
  sensors.setResolution(Probe02, 9);
  sensors.setResolution(Probe03, 9);
  sensors.setResolution(Probe04, 9);
  //sensors.setResolution(Probe05, 9); //uncomment for further DS18B20 sensor
  
///Logfile=SD.open("Logfile.csv",FILE_WRITE);               //Open and write once, just for headers
//Logfile.println(" Date/Time         Temp1   Temp2   Temp3    Temp4    Temp5   Hum5");    //Print headers(not saved yet) //////////
///Logfile.close();                                        //Print saved

bool status; //////////D
status = bme.begin(0x76); //////////D
delayTime = 1000; //////////D

}

//----------Temp Variable------------//
void printTemperature(DeviceAddress deviceAddress)
{
   float tempC = sensors.getTempC(deviceAddress);
 
   Logfile.print(tempC);
   Logfile.print(" C");
   Logfile.print(" ");
}

void loop()
{

 DateTime now = RTC.now();        // Clock call
 now = RTC.now();                 

if(now.second()==00){          //Sample every minute
 
 ///Logfile=SD.open("Logfile.csv",FILE_WRITE);  // Print date and time    
Logfile.println();
Logfile.print(now.year(), DEC);
Logfile.print("/");
Logfile.print(now.month(), DEC);
Logfile.print("/");
Logfile.print(now.day(), DEC);
Logfile.print(" ");
Logfile.print(now.hour(), DEC);
Logfile.print(":");
Logfile.print(now.minute(), DEC);
Logfile.print(":");
Logfile.print(now.second(), DEC);
Logfile.print("  ");              //Space beween date/time and temp1
///Logfile.close();                  //Save date and time

sensors.requestTemperatures(); // Command all devices on bus to read temperature 
///Logfile=SD.open("Logfile.csv",FILE_WRITE); 
  
 Logfile.print("Temp1: ");             //Print temp1
 printTemperature(Probe01);
 Logfile.print("Temp2: ");             //Print temp2
 printTemperature(Probe02);
 Logfile.print("Temp3: ");             //Print temp3
 printTemperature(Probe03);
 Logfile.print("Temp4: ");             //Print temp4
 printTemperature(Probe04);
 //Logfile.print("Temp5:");             //uncomment for further DS18B20 sensor //Print temp5
 //printTemperature(Probe05);

  int chkA = DHT.read21(DHT21A_PIN); //////////A
    //Read data and store it to variables hum and temp //////////A
    humA = DHT.humidity; //////////A
    tempA= DHT.temperature; //////////A
    //Print temp and humidity values to serial monitor //////////A
    Logfile.print("Hum6: "); //////////A
    Logfile.print(humA); //////////A
    Logfile.print(" %, Temp6: "); //////////A
    Logfile.print(tempA); //////////A
    Logfile.print(" C"); //////////A

    int chkB = DHT.read21(DHT21B_PIN); //////////B
    //Read data and store it to variables hum and temp //////////B
    humB = DHT.humidity; //////////B
    tempB= DHT.temperature; //////////B
    //Print temp and humidity values to serial monitor //////////B
    Logfile.print("Hum7: "); //////////B
    Logfile.print(humB); //////////B
    Logfile.print(" %, Temp7: "); //////////B
    Logfile.print(tempB); //////////B
    Logfile.print(" C"); //////////B

int i;  //////////C
        uint16_t val=0; //////////C
        BH1750_Init(BH1750address); //////////C
        delay(200);//////////C

        if(2==BH1750_Read(BH1750address)) { //////////C
                val=((buff[0]<<8)|buff[1])/1.2; //////////C
                Logfile.print("Light: "); ////////C
                Logfile.print(val,DEC);  //////////C
                Logfile.println("lx"); //////////C
        } //////////C
        delay(150); //////////C

    Logfile.print("Temperature = ");//////////D
    Logfile.print(bme.readTemperature());//////////D
    Logfile.println(" *C");//////////D
    Logfile.print("Pressure = ");//////////D
    Logfile.print(bme.readPressure() / 100.0F);//////////D
    Logfile.println(" hPa");//////////D
    Logfile.print("Humidity = ");//////////D
    Logfile.print(bme.readHumidity());//////////D
    Logfile.println(" %");//////////D
    
/// Logfile.close();                //Print saved
 }
 
delay(1000);                        //One data per second
}