adafruit / Adafruit_BME280_Library

Arduino Library for BME280 sensors
Other
328 stars 301 forks source link

Provide temperature compensation #84 #85

Closed jasonmf closed 4 years ago

jasonmf commented 4 years ago

Scope

A private member field is added to the class Adafruit_BME280: float t_fine_adjust

Limitations

A few degrees Celsius of temperature compensation result in only tiny changes in pressure and humidity.

Adjustment: 3
28.66 - 100066.50 - 30.76
Adjustment: 0
25.65 -- 99553.88 - 30.81
Adjustment: 3
28.71 - 100069.04 - 32.90
Adjustment: 0
25.73 -- 99555.32 - 34.43

Running:

#include <Arduino.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>

Adafruit_BME280 bme; // I2C

void setup() {
  Serial.begin(9600);
  if (! bme.begin(BME280_ADDRESS_ALTERNATE, &Wire)) {
    Serial.println("badness");
    while(1);
  }
  // bme.setTemperatureAdjustment(3);
}

void loop() {
  bme.setTemperatureAdjustment(3);
  Serial.println("Adjustment: 3");
  Serial.print(bme.readTemperature());
  Serial.print(" - ");
  Serial.print(bme.readPressure());
  Serial.print(" - ");
  Serial.println(bme.readHumidity());
  delay(1000);
  bme.setTemperatureAdjustment(0);
  Serial.println("Adjustment: 0");
  Serial.print(bme.readTemperature());
  Serial.print(" -- ");
  Serial.print(bme.readPressure());
  Serial.print(" - ");
  Serial.println(bme.readHumidity());
  delay(5000);
}
jasonmf commented 4 years ago

Bah, I didn't write the getter. Stand by.

jasonmf commented 4 years ago

Fixed

ladyada commented 4 years ago

nice, thank you :) can you change the name to xetTemperatureOffset or xetTemperatureCorrection, we think that might be easier to recognize

jasonmf commented 4 years ago

Done.

I notice you're reviewing and commenting on Saturday and Sunday. I hope you take days off.

ladyada commented 4 years ago

thanx - next up can you run clang-format -i on the files youve changed (or hand-adapt these diffs) https://github.com/adafruit/Adafruit_BME280_Library/runs/938637551#step:7:1

jasonmf commented 4 years ago

Done! I appreciate your time.

jasonmf commented 4 years ago

Done!

jasonmf commented 4 years ago

Fixed!

ladyada commented 4 years ago

awesome, its now passing CI - good work!