Hello all,
I am making a weather station with a BME-280 sensor and a data logging shield with an SD card.
The operation is correct, only when I open the values in Excel the values jump.
I can't get it fine tuned.
I have tried several things but without success.
Is there anyone who can help me a little bit, haven't been working with Arduino that long.
I also attached a screenshot of the Excel.
With regards Robert
//Weerstation met datalogging en klok
#include "SD.h" // voor de SD kaart
#include <Adafruit_Sensor.h> //voor de sensor
#include <Adafruit_BME280.h> //voor de BME280
#include <Wire.h> //onbekend
#include <RTClib.h> //voor de RTC-clock
Adafruit_BME280 bme; // I2C
File myFile; //Maak een file voor de gegevens op te slaan
RTC_DS1307 rtc; // Real Time Clock
const int chipSelect = 10; //SD-kaartlezer op pin 10
void setup() {
Serial.begin(9600); //initialiseren Serial Monitor
while(!Serial); //Tijd voor serial te laten starten
Serial.println(F("BME280 test"));
signed status;
status = bme.begin(0x76);
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("-- Standaard Test --");
delay(3000);
Serial.println();
if(!rtc.begin()) { //RTC initialisren
Serial.println("Kan geen RTC vinden");
while (1);
}
else {
rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); //Compileren van datum en tijd in de sketch
}
if(! rtc.isrunning()) {
Serial.println("RTC start niet!");
}
Serial.print("Initialiseren SD card..."); //Setup voor de SD-kaart
if(!SD.begin(chipSelect)) {
Serial.println("Initialiseren mislukt!");
return;
}
Serial.println("Initialiseren gelukt");
myFile=SD.open("DATA.txt", FILE_WRITE); //Openen van de DATA-file
if (myFile) {
Serial.println("File geopend ok"); //Print de gegevens voor de data
myFile.println("Datum, Tijd, Temperatuur ˚C, Luchtdruk Hpa, Luchtvochtigheid %");
}
myFile.close();
}
void loggingTime() {
DateTime now = rtc.now();
myFile=SD.open("DATA.txt", FILE_WRITE);
if (myFile) {
myFile.print(now.year(), DEC);
myFile.print('/');
myFile.print(now.month(), DEC);
myFile.print('/');
myFile.print(now.day(), DEC);
myFile.print("\t");
myFile.print(now.hour(), DEC);
myFile.print(':');
myFile.print(now.minute(), DEC);
myFile.print(':');
myFile.println(now.second(), DEC);
}
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.println(now.day(), DEC);
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
myFile.close();
delay(1000);
}
void loggingBME280() {
myFile=SD.open("DATA.txt", FILE_WRITE);
if (myFile) {
Serial.println("SD geopend met succes");
myFile.print("\t");
myFile.print("\t");
myFile.print(bme.readTemperature());
myFile.print("\t");
myFile.print(bme.readPressure() / 100.0F);
myFile.print("\t");
myFile.println(bme.readHumidity());
//myFile.print("\t");
}
Serial.print("Temperatuur = ");
Serial.print(bme.readTemperature());
Serial.println(" °C");
Serial.print("Luchtdruk = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
Serial.print("Luchtvochtigheid = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.println();
myFile.close();
delay(1000);
}
void loop() {
loggingTime();
loggingBME280();
delay(5000);
}


