コード例 #1
0
ファイル: BMP085_basic.cpp プロジェクト: 0w0miki/i2cdevlib
int main(int argc, char **argv) {
  printf("BMPO85 examples program\n");
  I2Cdev::initialize();
  BMP085 barometer ; // BMP085 class default I2C address is 0x77, specific I2C addresses may be passed as a parameter here
  if ( barometer.testConnection() ) 
    printf("BMP085 connection test successful\n") ;
  else {
    fprintf( stderr, "BMP085 connection test failed! exiting ...\n");
    return 1;
  }
  barometer.loadCalibration();
  float temperature;
  float pressure;
  float altitude;
  while (true) {
    barometer.setControl(BMP085_MODE_TEMPERATURE);
    bcm2835_delay(5); // wait 5 ms for conversion 
    temperature = barometer.getTemperatureC();
    barometer.setControl(BMP085_MODE_PRESSURE_3) ; //taking reading in highest accuracy measurement mode
    bcm2835_delay( barometer.getMeasureDelayMicroseconds() / 1000 );
    pressure = barometer.getPressure();
    altitude = barometer.getAltitude(pressure);
    printf("  Temperature: %3.1f deg C      Pressure %3.3f kPa      altitude %3.1f m\r", temperature, pressure/1000.0, altitude);
    fflush(stdout);
    bcm2835_delay(200);
  }
  return 1; 
}
コード例 #2
0
double Sensor::getBMP085altitude() {
    BMP085 dps = BMP085();  
    Wire.begin();
    dps.init();
    long Temperature = 0, Pressure = 0, Altitude = 0;
    dps.getTemperature(&Temperature); 
    dps.getPressure(&Pressure);
    dps.getAltitude(&Altitude);
    return (double) Altitude;
}
コード例 #3
0
double Sensor::getBMP085pressure() {
    Serial.println("At getPressure");
    BMP085 dps = BMP085();  
    Wire.begin();
    dps.init();
    long Temperature = 0, Pressure = 0, Altitude = 0;
    dps.getTemperature(&Temperature); 
    dps.getPressure(&Pressure);
    dps.getAltitude(&Altitude);
    Serial.print("The pressure is: ");Serial.println("Pressure");
    return (double) Pressure;
}