BME280 and MPU6050 data logger

hello people
I got a small problem. I have written this code a long time ago an I don’t know which pins numbers etc I use, I want to revisit this project an improve on it can one of you guide me how I can retrieve the data and proceed with this project.
kind regards pacmanpck

BME280_and_MPU6050_data_logger.ino (3.43 KB)

@pacmanpck

Your topic was Moved to it’s current location / section as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

first of al thank you for your on reaction. how can ik move it to a better location. you told me you where missing some data to what precisely are you referring because you know the sensor I referred them in the title the only thing you perhaps didn't know that I use a Arduino NANO is this enough information for you on this time

OP’s code

#include <Wire.h>
#include "BlueDot_BME280.h"
#include <MPU6050_tockn.h>
#include <SD.h>
#include <SPI.h>

BlueDot_BME280 bme280 = BlueDot_BME280();
MPU6050 mpu6050(Wire);

long timer = 0;

int chipselect = 4;
File Data;

void setup() {
Serial.begin(9600);
  
  if (bme280.init() != 0x60)
  {    
    
    
    Serial.println(F("Ops! BME280 could not be found!"));
   
    Serial.println();
    
    while(1);
  }

  else
  {
    Serial.println(F("BME280 detected!"));
  }
  Serial.println();
  Serial.println();
  Wire.begin();
  mpu6050.begin();
  mpu6050.calcGyroOffsets(true);
   mpu6050.calcGyroOffsets(true);
  pinMode(10,OUTPUT);
  SD.begin(chipselect);
}
void loop() 
{ 
  Data = SD.open("DATALOG.txt",FILE_WRITE);
 if (Data)  {
   
   Serial.print(F("Duration in Seconds:\t\t"));
   Serial.println(float(millis())/1000);
 
   Serial.print(F("Temperature in Celsius:\t\t")); 
   Serial.println(bme280.readTempC());
   
   Serial.print(F("Humidity in %:\t\t\t")); 
   Serial.println(bme280.readHumidity());

   Serial.print(F("Pressure in hPa:\t\t")); 
   Serial.println(bme280.readPressure());

   Serial.print(F("Altitude in Meters:\t\t")); 
   Serial.println(bme280.readAltitudeMeter()); 
   
   Serial.println();
   Serial.println();
    mpu6050.update();

  if(millis() - timer > 1000){
    
    Serial.println("=======================================================");
    Serial.print("temp : ");Serial.println(mpu6050.getTemp());
    Serial.print("accX : ");Serial.print(mpu6050.getAccX());
    Serial.print("\taccY : ");Serial.print(mpu6050.getAccY());
    Serial.print("\taccZ : ");Serial.println(mpu6050.getAccZ());
  
    Serial.print("gyroX : ");Serial.print(mpu6050.getGyroX());
    Serial.print("\tgyroY : ");Serial.print(mpu6050.getGyroY());
    Serial.print("\tgyroZ : ");Serial.println(mpu6050.getGyroZ());
  
    Serial.print("accAngleX : ");Serial.print(mpu6050.getAccAngleX());
    Serial.print("\taccAngleY : ");Serial.println(mpu6050.getAccAngleY());
  
    Serial.print("gyroAngleX : ");Serial.print(mpu6050.getGyroAngleX());
    Serial.print("\tgyroAngleY : ");Serial.print(mpu6050.getGyroAngleY());
    Serial.print("\tgyroAngleZ : ");Serial.println(mpu6050.getGyroAngleZ());
    
    Serial.print("angleX : ");Serial.print(mpu6050.getAngleX());
    Serial.print("\tangleY : ");Serial.print(mpu6050.getAngleY());
    Serial.print("\tangleZ : ");Serial.println(mpu6050.getAngleZ());
    Serial.println("=======================================================\n");
    timer = millis();
  delay(200);   
Data.print(bme280.readTempC());
Data.print(",");
Data.print(bme280.readHumidity());
Data.print(",");
Data.print(bme280.readPressure());
Data.print(",");
Data.print(bme280.readAltitudeMeter());
Data.print(",");
Data.print(mpu6050.getTemp());
Data.print(",");
Data.print(mpu6050.getAccX());
Data.print(",");
Data.print(mpu6050.getAccY());
Data.print(",");
Data.print(mpu6050.getAccZ());
Data.print(",");
Data.print(mpu6050.getGyroX());
Data.print(",");
Data.print(mpu6050.getGyroY());
Data.print(",");
Data.print(mpu6050.getGyroZ());
Data.print(",");
Data.print(mpu6050.getAccAngleX());
Data.print(",");
Data.print(mpu6050.getAccAngleY());
Data.print(",");
Data.print(mpu6050.getGyroAngleX());
Data.print(",");
Data.print(mpu6050.getGyroAngleY());
Data.print(",");
Data.print(mpu6050.getGyroAngleZ());
Data.print(",");
Data.print(mpu6050.getAngleX());
Data.print(",");
Data.print(mpu6050.getAngleY());
Data.print(",");
Data.println(mpu6050.getAngleZ());

Data.close();
 }
 }
 }

PLEASE USE CODE TAGS

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

I don't post these links for no reason so take advantage of them !

my sincere apologies for that I've read it a couple of times now and now I understand we'll see English is not my native language and I'm also a very heavy dyslexia so that might explain sumo the problems you encounter now again my sincere apologies for that I will delete the last post if that's possible therefore I shall recap it again if I fail again I will do the same thing and try again until I succeed

som time has passed since we lost talked since that time I've rewritten the complete code however I think I got further this time but there are a few things still wrong and I can't figure out what would you be so kind to help me I have included a picture of the errors I keep getting and I have added in text the code

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

const int chipSelect = 4;

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

long timer = 0;



void setup() {
Serial.begin(9600);
Wire.begin();
MPU6050.begin();
mpu6050.calcGyroOffset(true);

while(!Serial) {
  ; //wait for serial port to connect. needed for native USP port
}
Serial.println("card initialized.");
while(!Serial);    // time to get serial running
  
  Serial.println(F("BME280 test"));
}
}
  unsigned status;
    status = bme.begin();  

    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;
    }

void loop() {
String dataSring = "";

for (int analogPin = 0; analogPin < 3; analogpin++) {
  int sensor = analogRead(analogpin)
  dataString += String(sensor);
   if (analogPin < 2) {
      dataString += ",";
      }
      }
 File dataFile = SD.open("datalog.txt", FILE_WRITE);
if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
    // print to the serial port too:
    Serial.println(dataString);
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  }
    {

    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();
    Serial.println();
 


     
    if(millis() - timer > 500{

    Serial.println("=======================================================");
    Serial.print("temp : ");Serial.println(mpu6050.getTemp());
    Serial.print("accX : ");Serial.print(mpu6050.getAccX());
    Serial.print("\taccY : ");Serial.print(mpu6050.getAccY());
    Serial.print("\taccZ : ");Serial.println(mpu6050.getAccZ());
  
    Serial.print("gyroX : ");Serial.print(mpu6050.getGyroX());
    Serial.print("\tgyroY : ");Serial.print(mpu6050.getGyroY());
    Serial.print("\tgyroZ : ");Serial.println(mpu6050.getGyroZ());
  
    Serial.print("accAngleX : ");Serial.print(mpu6050.getAccAngleX());
    Serial.print("\taccAngleY : ");Serial.println(mpu6050.getAccAngleY());
  
    Serial.print("gyroAngleX : ");Serial.print(mpu6050.getGyroAngleX());
    Serial.print("\tgyroAngleY : ");Serial.print(mpu6050.getGyroAngleY());
    Serial.print("\tgyroAngleZ : ");Serial.println(mpu6050.getGyroAngleZ());
    
    Serial.print("angleX : ");Serial.print(mpu6050.getAngleX());
    Serial.print("\tangleY : ");Serial.print(mpu6050.getAngleY());
    Serial.print("\tangleZ : ");Serial.println(mpu6050.getAngleZ());
    Serial.println("=======================================================\n");
    timer = millis();

    delay(200);

Data.print(bme280.readTempC());
Data.print(",");
Data.print(bme280.readHumidity());
Data.print(",");
Data.print(bme280.readPressure());
Data.print(",");
Data.print(bme280.readAltitudeMeter());
Data.print(",");
Data.print(mpu6050.getTemp());
Data.print(",");
Data.print(mpu6050.getAccX());
Data.print(",");
Data.print(mpu6050.getAccY());
Data.print(",");
Data.print(mpu6050.getAccZ());
Data.print(",");
Data.print(mpu6050.getGyroX());
Data.print(",");
Data.print(mpu6050.getGyroY());
Data.print(",");
Data.print(mpu6050.getGyroZ());
Data.print(",");
Data.print(mpu6050.getAccAngleX());
Data.print(",");
Data.print(mpu6050.getAccAngleY());
Data.print(",");
Data.print(mpu6050.getGyroAngleX());
Data.print(",");
Data.print(mpu6050.getGyroAngleY());
Data.print(",");
Data.print(mpu6050.getGyroAngleZ());
Data.print(",");
Data.print(mpu6050.getAngleX());
Data.print(",");
Data.print(mpu6050.getAngleY());
Data.print(",");
Data.println(mpu6050.getAngleZ());

Data.close();
    
}

@pacmanpck

We do have some other language options available.

if you would like your post moved please use the "report to moderator" option

thank you for that for now I wil keep to English I think I get a bigger audience if I ask a question was the provided information now wel oké to work with

Ok, I will try a reply again. My last one was lost as I was apparently logged out, and the message was not accepted.

Please look thru this to my <<<<< comments

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

const int chipSelect = 4;  <<<< could be byte, value is <=255

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

long timer = 0;  <<<< should be unsigned long, that is what millis(), micros() are returning

void setup() {
Serial.begin(9600);   <<<< why so slow? Serial Monitor works well at 115200
Wire.begin();
MPU6050.begin();
mpu6050.calcGyroOffset(true);

while(!Serial) {                   <<<<< This section is not needed if your processor does nat USB built in,
  ; //wait for serial port to connect. needed for native USP port   <<<<< such as 328P, 1284P, 2560
}
Serial.println("card initialized.");
while(!Serial);    // time to get serial running
 
  Serial.println(F("BME280 test"));
}
}   <<<<< do a CTRL-T in the IDE (Tools:Autoformat), it will show you have too many }. Fix that.
  unsigned status;
    status = bme.begin(); 

    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;   <<<< what is this doing? Data type is not declared, and it assigns a value, that is never used.
    }

void loop() {
String dataSring = "";   <<<< variable name does not match spelling used elsewhere

for (int analogPin = 0; analogPin < 3; analogpin++) {
  int sensor = analogRead(analogpin)                  <<<<< missing a ; here
dataString += String(sensor);
   if (analogPin < 2) {
      dataString += ",";
      }
      }
 File dataFile = SD.open("datalog.txt", FILE_WRITE);
if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
    // print to the serial port too:
    Serial.println(dataString);
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  }
    { <<<<<  What is this for?

    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();
    Serial.println();
     
    if(millis() - timer > 500{
    Serial.println("=======================================================");
    Serial.print("temp : ");Serial.println(mpu6050.getTemp());
    Serial.print("accX : ");Serial.print(mpu6050.getAccX());
    Serial.print("\taccY : ");Serial.print(mpu6050.getAccY());
    Serial.print("\taccZ : ");Serial.println(mpu6050.getAccZ());
 
    Serial.print("gyroX : ");Serial.print(mpu6050.getGyroX());
    Serial.print("\tgyroY : ");Serial.print(mpu6050.getGyroY());
    Serial.print("\tgyroZ : ");Serial.println(mpu6050.getGyroZ());
 
    Serial.print("accAngleX : ");Serial.print(mpu6050.getAccAngleX());
    Serial.print("\taccAngleY : ");Serial.println(mpu6050.getAccAngleY());
 
    Serial.print("gyroAngleX : ");Serial.print(mpu6050.getGyroAngleX());
    Serial.print("\tgyroAngleY : ");Serial.print(mpu6050.getGyroAngleY());
    Serial.print("\tgyroAngleZ : ");Serial.println(mpu6050.getGyroAngleZ());
   
    Serial.print("angleX : ");Serial.print(mpu6050.getAngleX());
    Serial.print("\tangleY : ");Serial.print(mpu6050.getAngleY());
    Serial.print("\tangleZ : ");Serial.println(mpu6050.getAngleZ());
    Serial.println("=======================================================\n");
    timer = millis();  <<<<< are you trying to print all the stuff every 1/2 second (500ms)? This millis() will be well after the millis() above all the Serial.print()s above, especially at 9600

    delay(200);  <<<<< What's delay for? You are already limiting things to every 500+ms, or will be once you get the { } pairings correct.

Data.print(bme280.readTempC());
Data.print(",");
Data.print(bme280.readHumidity());
Data.print(",");
Data.print(bme280.readPressure());
Data.print(",");
Data.print(bme280.readAltitudeMeter());
Data.print(",");
Data.print(mpu6050.getTemp());
Data.print(",");
Data.print(mpu6050.getAccX());
Data.print(",");
Data.print(mpu6050.getAccY());
Data.print(",");
Data.print(mpu6050.getAccZ());
Data.print(",");
Data.print(mpu6050.getGyroX());
Data.print(",");
Data.print(mpu6050.getGyroY());
Data.print(",");
Data.print(mpu6050.getGyroZ());
Data.print(",");
Data.print(mpu6050.getAccAngleX());
Data.print(",");
Data.print(mpu6050.getAccAngleY());
Data.print(",");
Data.print(mpu6050.getGyroAngleX());
Data.print(",");
Data.print(mpu6050.getGyroAngleY());
Data.print(",");
Data.print(mpu6050.getGyroAngleZ());
Data.print(",");
Data.print(mpu6050.getAngleX());
Data.print(",");
Data.print(mpu6050.getAngleY());
Data.print(",");
Data.println(mpu6050.getAngleZ());

Data.close();
   
}

Another issue is that you have no declaration of an MPU6050 object. Looking at a GitHub example I see:

MPU6050 mpu6050(Wire);

thank all of you for your tips and tricks however there are still a few complications if you would be so kind to look at it again that woud be great I have edit the code

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

MPU6050 mpu6050(Wire);

const int chipSelect = 255; 

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

long timer = 0; // <<<< should be unsigned long, that is what millis(), micros() are returning

void setup() {
  Serial.begin(115200);  
  Wire.begin();
  mpu6050.begin();
  mpu6050.calcGyroOffsets(true);

  //while(!Serial) {                   <<<<< This section is not needed if your processor does nat USB built in,
  ; //wait for serial port to connect. needed for native USP port   <<<<< such as 328P, 1284P, 2560
}
//Serial.println("card initialized.");
//while(!Serial);    // time to get serial running

Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI


//  Serial.println(F("BME280 test"));

//}   <<< << do a CTRL - T in the IDE (Tools: Autoformat), it will show you have too many } . Fix that.
unsigned status;
status = bme.begin();

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;   <<<< what is this doing? Data type is not declared, and it assigns a value, that is never used.
}

void loop() {
  String dataSring = "";   <<< < variable name does not match spelling used elsewhere

  for (int analogPin = 0; analogPin < 3; analogpin++) {
    int sensor = analogRead(analogpin); 
    dataString += String(sensor);
    if (analogPin < 2) {
      dataString += ",";
    }
  }
  File dataFile = SD.open("datalog.txt", FILE_WRITE);
  if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
    // print to the serial port too:
    Serial.println(dataString);
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  }
  //{ <<<<<  What is this for?

  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();
  Serial.println();

  if (millis() - timer > 500{
  Serial.println("=======================================================");
    Serial.print("temp : "); Serial.println(mpu6050.getTemp());
    Serial.print("accX : "); Serial.print(mpu6050.getAccX());
    Serial.print("\taccY : "); Serial.print(mpu6050.getAccY());
    Serial.print("\taccZ : "); Serial.println(mpu6050.getAccZ());

    Serial.print("gyroX : "); Serial.print(mpu6050.getGyroX());
    Serial.print("\tgyroY : "); Serial.print(mpu6050.getGyroY());
    Serial.print("\tgyroZ : "); Serial.println(mpu6050.getGyroZ());

    Serial.print("accAngleX : "); Serial.print(mpu6050.getAccAngleX());
    Serial.print("\taccAngleY : "); Serial.println(mpu6050.getAccAngleY());

    Serial.print("gyroAngleX : "); Serial.print(mpu6050.getGyroAngleX());
    Serial.print("\tgyroAngleY : "); Serial.print(mpu6050.getGyroAngleY());
    Serial.print("\tgyroAngleZ : "); Serial.println(mpu6050.getGyroAngleZ());

    Serial.print("angleX : "); Serial.print(mpu6050.getAngleX());
    Serial.print("\tangleY : "); Serial.print(mpu6050.getAngleY());
    Serial.print("\tangleZ : "); Serial.println(mpu6050.getAngleZ());
    Serial.println("=======================================================\n");
    timer = millis();  <<< << are you trying to print all the stuff every 1 / 2 second (500ms) ? This millis() will be well after the millis() above all the Serial.print()s above, especially at 115200

    Data.print(bme280.readTempC());
    Data.print(",");
    Data.print(bme280.readHumidity());
    Data.print(",");
    Data.print(bme280.readPressure());
    Data.print(",");
    Data.print(bme280.readAltitudeMeter());
    Data.print(",");
    Data.print(mpu6050.getTemp());
    Data.print(",");
    Data.print(mpu6050.getAccX());
    Data.print(",");
    Data.print(mpu6050.getAccY());
    Data.print(",");
    Data.print(mpu6050.getAccZ());
    Data.print(",");
    Data.print(mpu6050.getGyroX());
    Data.print(",");
    Data.print(mpu6050.getGyroY());
    Data.print(",");
    Data.print(mpu6050.getGyroZ());
    Data.print(",");
    Data.print(mpu6050.getAccAngleX());
    Data.print(",");
    Data.print(mpu6050.getAccAngleY());
    Data.print(",");
    Data.print(mpu6050.getGyroAngleX());
    Data.print(",");
    Data.print(mpu6050.getGyroAngleY());
    Data.print(",");
    Data.print(mpu6050.getGyroAngleZ());
    Data.print(",");
    Data.print(mpu6050.getAngleX());
    Data.print(",");
    Data.print(mpu6050.getAngleY());
    Data.print(",");
    Data.println(mpu6050.getAngleZ());

    Data.close();

  }

Schermafbeelding 2020-11-30 om 21.57.06.png

Schermafbeelding 2020-11-30 om 21.57.06.png

unsigned status;

unsigned what? byte, int, long?

Did you try CTRL-T?
I did, it still shows you have too many right curly braces.
Go thru and make sure each { has a mating }, and they encompass what you are expecting.

You can click your cursor next to a } and then use the scroll bar to work back and find it's mate.

hello people after almost 3 days of continuous coding and troubleshooting I have figured it out so I'm in a quad good mood however there is another problem I can see only one of the sensors I can read only one of the values while I still need both of the values is there who has encountered this problem before and can you give me a tip or something below this I've added a picture in the code itself you can see for yourself why it stopped halfway because I'm out of ideas

#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#include <MPU6050_tockn.h>

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

Adafruit_BMP280 bme; // I2C
//Adafruit_BMP280 bme(BMP_CS); // hardware SPI
//Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);

MPU6050 mpu6050(Wire);


void setup() {
  Serial.begin(9600);
  Wire.begin();
  mpu6050.begin();
  mpu6050.calcGyroOffsets(true);

  
Serial.println(F("BMP280 test"));
 
if (!bme.begin(0x76)) {
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}
}

void loop() {
  

    Serial.print("Temperature = ");
    Serial.print(bme.readTemperature());
    Serial.println(" *C");
 
    Serial.print("Pressure = ");
    Serial.print(bme.readPressure());
    Serial.println(" Pa");
 
    Serial.print("Approx altitude = ");
    Serial.print(bme.readAltitude(1014.25)); // this should be adjusted to your local forcase
    Serial.println(" m");
 
    Serial.println();
    delay(2000);
    

    Serial.println();
     mpu6050.update();

    Serial.println("=======================================================");
    Serial.print("temp : ");Serial.println(mpu6050.getTemp());
    Serial.print("accX : ");Serial.print(mpu6050.getAccX());
    Serial.print("\taccY : ");Serial.print(mpu6050.getAccY());
    Serial.print("\taccZ : ");Serial.println(mpu6050.getAccZ());
  
    Serial.print("gyroX : ");Serial.print(mpu6050.getGyroX());
    Serial.print("\tgyroY : ");Serial.print(mpu6050.getGyroY());
    Serial.print("\tgyroZ : ");Serial.println(mpu6050.getGyroZ());
  
    Serial.print("accAngleX : ");Serial.print(mpu6050.getAccAngleX());
    Serial.print("\taccAngleY : ");Serial.println(mpu6050.getAccAngleY());
  
    Serial.print("gyroAngleX : ");Serial.print(mpu6050.getGyroAngleX());
    Serial.print("\tgyroAngleY : ");Serial.print(mpu6050.getGyroAngleY());
    Serial.print("\tgyroAngleZ : ");Serial.println(mpu6050.getGyroAngleZ());
    
    Serial.print("angleX : ");Serial.print(mpu6050.getAngleX());
    Serial.print("\tangleY : ");Serial.print(mpu6050.getAngleY());
    Serial.print("\tangleZ : ");Serial.println(mpu6050.getAngleZ());
    Serial.println("=======================================================\n");
    delay(500);
    
  

}

Schermafbeelding 2020-12-02 om 19.53.52.png

Schermafbeelding 2020-12-02 om 19.53.52.png