Merge pull request #85 from AgentZombie/temp-adjust-84
Provide temperature compensation #84
This commit is contained in:
commit
12a6729e36
|
|
@ -419,7 +419,7 @@ float Adafruit_BME280::readTemperature(void) {
|
||||||
((int32_t)_bme280_calib.dig_T3)) >>
|
((int32_t)_bme280_calib.dig_T3)) >>
|
||||||
14;
|
14;
|
||||||
|
|
||||||
t_fine = var1 + var2;
|
t_fine = var1 + var2 + t_fine_adjust;
|
||||||
|
|
||||||
float T = (t_fine * 5 + 128) >> 8;
|
float T = (t_fine * 5 + 128) >> 8;
|
||||||
return T / 100;
|
return T / 100;
|
||||||
|
|
@ -540,6 +540,24 @@ float Adafruit_BME280::seaLevelForAltitude(float altitude, float atmospheric) {
|
||||||
*/
|
*/
|
||||||
uint32_t Adafruit_BME280::sensorID(void) { return _sensorID; }
|
uint32_t Adafruit_BME280::sensorID(void) { return _sensorID; }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the current temperature compensation value in degrees Celcius
|
||||||
|
* @returns the current temperature compensation value in degrees Celcius
|
||||||
|
*/
|
||||||
|
float Adafruit_BME280::getTemperatureCompensation(void) {
|
||||||
|
return float(((t_fine_adjust * 5) >> 8) / 100);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets a value to be added to each temperature reading. This adjusted
|
||||||
|
* temperature is used in pressure and humidity readings.
|
||||||
|
* @param adjustment Value to be added to each tempature reading in Celcius
|
||||||
|
*/
|
||||||
|
void Adafruit_BME280::setTemperatureCompensation(float adjustment) {
|
||||||
|
// convert the value in C into and adjustment to t_fine
|
||||||
|
t_fine_adjust = ((int32_t(adjustment * 100) << 8)) / 5;
|
||||||
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@brief Gets an Adafruit Unified Sensor object for the temp sensor component
|
@brief Gets an Adafruit Unified Sensor object for the temp sensor component
|
||||||
@return Adafruit_Sensor pointer to temperature sensor
|
@return Adafruit_Sensor pointer to temperature sensor
|
||||||
|
|
|
||||||
|
|
@ -234,6 +234,9 @@ public:
|
||||||
float seaLevelForAltitude(float altitude, float pressure);
|
float seaLevelForAltitude(float altitude, float pressure);
|
||||||
uint32_t sensorID(void);
|
uint32_t sensorID(void);
|
||||||
|
|
||||||
|
float getTemperatureCompensation(void);
|
||||||
|
void setTemperatureCompensation(float);
|
||||||
|
|
||||||
Adafruit_Sensor *getTemperatureSensor(void);
|
Adafruit_Sensor *getTemperatureSensor(void);
|
||||||
Adafruit_Sensor *getPressureSensor(void);
|
Adafruit_Sensor *getPressureSensor(void);
|
||||||
Adafruit_Sensor *getHumiditySensor(void);
|
Adafruit_Sensor *getHumiditySensor(void);
|
||||||
|
|
@ -274,6 +277,9 @@ protected:
|
||||||
int8_t _miso; //!< for the SPI interface
|
int8_t _miso; //!< for the SPI interface
|
||||||
int8_t _sck; //!< for the SPI interface
|
int8_t _sck; //!< for the SPI interface
|
||||||
|
|
||||||
|
int32_t t_fine_adjust = 0; //!< add to compensate temp readings and in turn
|
||||||
|
//!< to pressure and humidity readings
|
||||||
|
|
||||||
bme280_calib_data _bme280_calib; //!< here calibration data is stored
|
bme280_calib_data _bme280_calib; //!< here calibration data is stored
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue