Code Monkey home page Code Monkey logo

bme280's Introduction

BME280

Arduino Source for the Bosch BME280 MOD-1022 Weather Multi Sensor

Using the Library

// need to read the NVM compensation parameters

 BME280.readCompensationParams();
 
 // Need to turn on 1x oversampling, default is os_skipped, which means it doesn't measure anything
 
 BME280.writeOversamplingPressure(os1x);  // 1x over sampling (ie, just one sample)
 BME280.writeOversamplingTemperature(os1x);
 BME280.writeOversamplingHumidity(os1x);
 
 // example of a forced sample.  After taking the measurement the chip goes back to sleep
 
 BME280.writeMode(smForced);
 while (BME280.isMeasuring()) {
   Serial.println("Measuring...");
   delay(50);
 }
 Serial.println("Done!");
 
 // read out the data - must do this before calling the getxxxxx routines
 
 BME280.readMeasurements();
 Serial.print("Temp=");
 Serial.println(BME280.getTemperature());  // must get temp first
 Serial.print("Humidity=");
 Serial.println(BME280.getHumidity());
 Serial.print("Pressure=");
 Serial.println(BME280.getPressure());
 Serial.print("PressureMoreAccurate=");
 Serial.println(BME280.getPressureMoreAccurate());  // use int64 calculcations
 Serial.print("TempMostAccurate=");
 Serial.println(BME280.getTemperatureMostAccurate());  // use double calculations
 Serial.print("HumidityMostAccurate=");
 Serial.println(BME280.getHumidityMostAccurate()); // use double calculations
 Serial.print("PressureMostAccurate=");
 Serial.println(BME280.getPressureMostAccurate()); // use double calculations

To switch to "normal" mode, we measurements are made regularly and you can take advatage of the built in smoothing

// Example for "indoor navigation"
// We'll switch into normal mode for regular automatic samples

BME280.writeStandbyTime(tsb_0p5ms);        // tsb = 0.5ms
BME280.writeFilterCoefficient(fc_16);      // IIR Filter coefficient 16
BME280.writeOversamplingPressure(os16x);    // pressure x16
BME280.writeOversamplingTemperature(os2x);  // temperature x2
BME280.writeOversamplingHumidity(os1x);     // humidity x1

BME280.writeMode(smNormal);
 
while (1) {
  
  
  while (BME280.isMeasuring()) {


  }
  
  // read out the data - must do this before calling the getxxxxx routines
  BME280.readMeasurements();
  printCompensatedMeasurements();
  
  delay(5000);	// do this every 5 seconds
  Serial.println();
}
}

bme280's People

Contributors

iharris avatar dr4nc3s avatar frostybeard avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.