void setup()

in 02_Firmware/windturbine/windturbine.ino [41:93]


void setup() {
  Wire.setClock(200000); // 400kHz I2C clock (200kHz if CPU is 8MHz)
  
  Serial.begin(BAUD_RATE);
  while (Serial.available() && Serial.read()); // empty buffer

  pinMode(VOLTAGE_PIN, INPUT);
  pinMode(LIGHT_PIN, INPUT);
  pinMode(LIGHT_WIND_SPEED_PIN, INPUT);

  if (!bme.begin()) {
    errorCode = 1;
    return;
  }

  mpu.initialize();
  // verify connection
  if (!mpu.testConnection()) {
    // Device communication error
    errorCode = 2;
    return;
  } // if

  // load and configure the DMP
  if (mpu.dmpInitialize() != 0 ) {
    // DMP initialization error
    errorCode = 3;
    return;
  } // if  

  // supply your own gyro offsets here, scaled for min sensitivity
  mpu.setXGyroOffset(-616);
  mpu.setYGyroOffset(-46);
  mpu.setZGyroOffset(5);
  mpu.setXAccelOffset(-1430);
  mpu.setYAccelOffset(-552);
  mpu.setZAccelOffset(1276);
  // Calibration Time: generate offsets and calibrate our MPU6050
  mpu.CalibrateAccel(6);
  mpu.CalibrateGyro(6);
  
  mpu.setDMPEnabled(true);
  
  // get expected DMP packet size for later comparison
  packetSize = mpu.dmpGetFIFOPacketSize();  

//  // Set up oversampling and filter initialization
  bme.setTemperatureOversampling(BME680_OS_8X);
  bme.setHumidityOversampling(BME680_OS_2X);
  bme.setPressureOversampling(BME680_OS_4X);
  bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
  bme.setGasHeater(320, 150); // 320*C for 150 ms
}