SRK Version of mDot LoRa_Sensormode_SRK
Dependencies: libmDot mbed-rtos mbed
Fork of mDot_LoRa_Sensornode by
BME280.h
00001 /* 00002 * BME280.h 00003 * 00004 * Created on: 18.05.2016 00005 * Author: Adrian 00006 */ 00007 #include <stdint.h> 00008 #include "I2C_RT.h " 00009 #include "BME280Config.h " 00010 00011 #ifndef APP_BME280_H_ 00012 #define APP_BME280_H_ 00013 00014 00015 #define BME280_SENSOR_ADDRESS 0b11101110 /**< Sensor address */ 00016 #define BME280_SENSOR_ID 0xD0 /**< ID of BMP280 */ 00017 #define BME280_SENSOR_RESET 0xE0 /**< Reset sensor */ 00018 #define BME280_SENSOR_CTRL_HUM 0xF2 /**< */ 00019 #define BME280_SENSOR_STATUS 0xF3 /**< */ 00020 #define BME280_SENSOR_CTRL_MEAS 0xF4 /**< */ 00021 #define BME280_SENSOR_CONFIG 0xF5 /**< */ 00022 #define BME280_SENSOR_PRESS_MSB 0xF7 /**< MSB of pressure value */ 00023 #define BME280_SENSOR_PRESS_LSB 0xF8 /**< LSB of pressure value */ 00024 #define BME280_SENSOR_PRESS_XLSB 0xF9 /**< xtra-LSB of pressure value */ 00025 #define BME280_SENSOR_TEMP_MSB 0x00FA /**< MSB of temperature value */ 00026 #define BME280_SENSOR_TEMP_LSB 0x00FB /**< LSB of temperature value */ 00027 #define BME280_SENSOR_TEMP_XLSB 0x00FC /**< xtra-LSB of temperature value */ 00028 #define BME280_SENSOR_HUM_MSB 0xFD /**< MSB of humidity value */ 00029 #define BME280_SENSOR_HUM_LSB 0xFE /**< xtra-LSB of humidity value */ 00030 00031 00032 #define BME280_digT1_LSB 0x88 /**< Trimming parameter for temperature */ 00033 #define BME280_digT1_MSB 0x89 /**< Trimming parameter for temperature */ 00034 #define BME280_digT2_LSB 0x8A /**< Trimming parameter for temperature */ 00035 #define BME280_digT2_MSB 0x8B /**< Trimming parameter for temperature */ 00036 #define BME280_digT3_LSB 0x8C /**< Trimming parameter for temperature */ 00037 #define BME280_digT3_MSB 0x8D /**< Trimming parameter for temperature */ 00038 00039 #define BME280_digP1_LSB 0x8E /**< Trimming parameter for pressure */ 00040 #define BME280_digP1_MSB 0x8F /**< Trimming parameter for pressure */ 00041 #define BME280_digP2_LSB 0x90 /**< Trimming parameter for pressure */ 00042 #define BME280_digP2_MSB 0x91 /**< Trimming parameter for pressure */ 00043 #define BME280_digP3_LSB 0x92 /**< Trimming parameter for pressure */ 00044 #define BME280_digP3_MSB 0x93 /**< Trimming parameter for pressure */ 00045 #define BME280_digP4_LSB 0x94 /**< Trimming parameter for pressure */ 00046 #define BME280_digP4_MSB 0x95 /**< Trimming parameter for pressure */ 00047 #define BME280_digP5_LSB 0x96 /**< Trimming parameter for pressure */ 00048 #define BME280_digP5_MSB 0x97 /**< Trimming parameter for pressure */ 00049 #define BME280_digP6_LSB 0x98 /**< Trimming parameter for pressure */ 00050 #define BME280_digP6_MSB 0x99 /**< Trimming parameter for pressure */ 00051 #define BME280_digP7_LSB 0x9A /**< Trimming parameter for pressure */ 00052 #define BME280_digP7_MSB 0x9B /**< Trimming parameter for pressure */ 00053 #define BME280_digP8_LSB 0x9C /**< Trimming parameter for pressure */ 00054 #define BME280_digP8_MSB 0x9D /**< Trimming parameter for pressure */ 00055 #define BME280_digP9_LSB 0x9E /**< Trimming parameter for pressure */ 00056 #define BME280_digP9_MSB 0x9F /**< Trimming parameter for pressure */ 00057 00058 #define BME280_digH1_LSB 0xA1 /**< Trimming parameter for humidity */ 00059 #define BME280_digH2_LSB 0xE1 /**< Trimming parameter for humidity */ 00060 #define BME280_digH2_MSB 0xE2 /**< Trimming parameter for humidity */ 00061 #define BME280_digH3_LSB 0xE3 /**< Trimming parameter for humidity */ 00062 #define BME280_digH4_MSB 0xE4 /**< Trimming parameter for humidity */ 00063 #define BME280_digH4_LSB 0xE5 /**< Trimming parameter for humidity */ 00064 #define BME280_digH5_LSB 0xE6 /**< Trimming parameter for humidity */ 00065 #define BME280_digH5_MSB 0xE5 /**< Trimming parameter for humidity */ 00066 #define BME280_digH6_LSB 0xE7 /**< Trimming parameter for humidity */ 00067 00068 class BME280 { 00069 public: 00070 BME280(I2C_RT*); 00071 virtual ~BME280(); 00072 void init(BME280_MODE); 00073 void setI2C(I2C_RT*); 00074 00075 00076 /** 00077 * @brief Gets the temperature in �C 00078 * @return temperature in �C 00079 */ 00080 float getTemperatureFloat(); 00081 00082 /** 00083 * @brief Gets the pressure in hPa 00084 * @return pressure in hPa 00085 */ 00086 float getPressureFloat(); 00087 00088 /** 00089 * @brief Gets the humidity in % 00090 * @return humidity in % 00091 */ 00092 float getHumidityFloat(); 00093 00094 private: 00095 I2C_RT* i2c; 00096 BME280Config* config; 00097 00098 uint16_t digT1; 00099 int16_t digT2; 00100 int16_t digT3; 00101 uint8_t digH1; 00102 int16_t digH2; 00103 uint8_t digH3; 00104 int16_t digH4; 00105 int16_t digH5; 00106 int8_t digH6; 00107 uint16_t digP1; 00108 int16_t digP2; 00109 int16_t digP3; 00110 int16_t digP4; 00111 int16_t digP5; 00112 int16_t digP6; 00113 int16_t digP7; 00114 int16_t digP8; 00115 int16_t digP9; 00116 00117 /** 00118 * Converts a raw measured humidity value in to an exact humidity value. The algorithm 00119 * was defined by Bosch itself 00120 * @param humidity_raw the raw measured humidity value 00121 * @param temperature_fine the exact temperature value 00122 * @return an exact humidity value 00123 */ 00124 int32_t compensateHumidity(int32_t humidity_raw, int32_t temperature_fine); 00125 00126 /** 00127 * Converts a raw measured pressure value in to an exact pressure value. The algorithm 00128 * was defined by Bosch itself 00129 * @param pressure_raw the raw measured pressure value 00130 * @param temperature_fine the exact temperature value 00131 * @return an exact pressure value 00132 */ 00133 int64_t compensatePressure(int32_t pressure_raw, int32_t temperature_fine); 00134 00135 /** 00136 * Converts a raw measured temperature value in to an exact temperature value. The algorithm 00137 * was defined by Bosch itself 00138 * @param temperatur_raw the raw measured temperature value 00139 * @return an exact temperature value 00140 */ 00141 int32_t compensateTemperature(int32_t temperature_raw); 00142 00143 00144 /** 00145 * @brief Reads the trim Values that are used for calculation the exact Humidity by the compensateHumidity() Method from 00146 * the Sensor Registers and stores them 00147 */ 00148 void getTrimValuesHumidity(); 00149 00150 /** 00151 * @brief Reads the trim Values that are used for calculation the exact Pressure by the compensatePressure() Method from 00152 * the Sensor Registers and stores them 00153 */ 00154 void getTrimValuesPressure(); 00155 00156 /** 00157 * @brief Reads the trim Values that are used for calculation the exact Temperature by the compensateTemperature() Method from 00158 * the Sensor Registers and stores them 00159 */ 00160 void getTrimValuesTemperature(); 00161 00162 00163 /** 00164 * @brief sets the Sensor in a special low Power Mode that is optimized for wheater Monitoring 00165 */ 00166 void setWeatherMonitoringMode(); 00167 00168 /** 00169 * @brief sets the Oversampling for Temperature Measurements 00170 */ 00171 void setOversamplingTemperature(uint8_t overSamplingTemperature); 00172 00173 /** 00174 * @brief sets the Oversampling for Pressure Measurements 00175 */ 00176 void setOversamplingPressure(uint8_t overSamplingPressure); 00177 00178 /** 00179 * @brief sets the Oversampling for Humidity Measurements 00180 */ 00181 void setOversamplingHumidity(uint8_t overSamplingHumidity); 00182 00183 /** 00184 * @brief sets the internal Sensor Mode inside the CTRL_MEAS Register 00185 */ 00186 void setMode(uint8_t desiredMode); 00187 00188 00189 /** 00190 * Get the raw Value of Humidity from the registers. This Value later needs to be processed 00191 * by the compensateHumidity() Method to get the exact Humidity 00192 * @return raw Humidity Value 00193 */ 00194 uint32_t getHumidity(); 00195 00196 /** 00197 * Get the raw Value of Pressure from the registers. This Value later needs to be processed 00198 * by the compensatePressure() Method to get the exact Pressure 00199 * @return raw Pressure Value 00200 */ 00201 uint32_t getPressure(); 00202 00203 /** 00204 * Get the raw Value of Temperature from the registers. This Value later needs to be processed 00205 * by the compensateTemperature() Method to get the exact Temperature 00206 * @return raw Temperature Value 00207 */ 00208 int32_t getTemperature(); 00209 00210 }; 00211 00212 #endif /* APP_BME280_H_ */
Generated on Wed Jul 13 2022 09:23:47 by 1.7.2