mbed library for Bosch BMX055 sensor
Dependents: Auto_pilot_prototype_3_2 Auto_pilot_prototype_3_2_os_2
Revision 1:b387585de3b5, committed 2020-07-25
- Comitter:
- Joeatsumi
- Date:
- Sat Jul 25 11:02:21 2020 +0000
- Parent:
- 0:3df2d4d2d393
- Commit message:
- This is a modified library of BMX055. This enables us to use BMX055 and BME280 sensor with a I2c bus.
Changed in this revision
test_BMX055.cpp | Show annotated file Show diff for this revision Revisions of this file |
test_BMX055.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 3df2d4d2d393 -r b387585de3b5 test_BMX055.cpp --- a/test_BMX055.cpp Sat May 23 13:17:09 2020 +0000 +++ b/test_BMX055.cpp Sat Jul 25 11:02:21 2020 +0000 @@ -1,16 +1,31 @@ #include "mbed.h" #include "test_BMX055.h" -test_BMX055::test_BMX055(PinName sda,PinName scl):i2c(sda ,scl){ +/* +test_BMX055::test_BMX055(PinName sda,PinName scl, char slave_adr):i2c(sda ,scl),address(slave_adr),t_fine(0){ //I2C initialization - i2c.frequency(400000); //400 kHz + i2c.frequency(100000); //100 kHz currentGyroRange = 0; currentAcceleroRange=0; gravity=9.80665; RAD_TO_DEG=57.3; - } +} +*/ +//BME280::BME280(I2C &i2c_obj, char slave_adr) + +test_BMX055::test_BMX055(I2C &i2c_obj, char slave_adr):i2c(i2c_obj),address(slave_adr),t_fine(0){ + + //I2C initialization + i2c.frequency(100000); //100 kHz + + currentGyroRange = 0; + currentAcceleroRange=0; + gravity=9.80665; + RAD_TO_DEG=57.3; +} + test_BMX055::~test_BMX055(){ } @@ -28,7 +43,7 @@ return; } - + //i2c read function int test_BMX055::i2c_mem_read(int device_address, int mem_address) { @@ -107,7 +122,7 @@ y_data = -1 * (65536 - y_data); } - y_rate=(float(y_data) * gyro_scale_factor)/RAD_TO_DEG; // deg/sec + y_rate=(float(y_data) * gyro_scale_factor)/RAD_TO_DEG; // rad/sec return y_rate; } @@ -130,7 +145,7 @@ z_data = -1 * z_data; - z_rate=(float(z_data) * gyro_scale_factor)/RAD_TO_DEG; // deg/sec + z_rate=(float(z_data) * gyro_scale_factor)/RAD_TO_DEG; // rad/sec return z_rate; } @@ -174,7 +189,7 @@ x_data = -1 * (4096 - x_data); } - x_acc=float(x_data)*gravity/acc_scale_factor; + x_acc=float(x_data)*gravity/acc_scale_factor;//m/s^2 return x_acc; } @@ -198,7 +213,7 @@ y_data = -1 * (4096 - y_data); } - y_acc=float(y_data)*gravity/acc_scale_factor; + y_acc=float(y_data)*gravity/acc_scale_factor;//m/s^2 return y_acc; } @@ -219,10 +234,10 @@ int z_data = z_temp_L + 16 * z_temp_H; if(z_data > 2047) { - z_data = (4096 - z_data); + z_data = -1*(4096 - z_data); } - z_acc=float(z_data)*gravity/acc_scale_factor; + z_acc=float(-z_data)*gravity/acc_scale_factor;//m/s^2 return z_acc; } @@ -230,24 +245,24 @@ void test_BMX055::initiate_mag() { i2c_mem_write(MAG_ADDRESS, 0x4b, 0x83); - wait_ms(10); + wait_us(10000); i2c_mem_write(MAG_ADDRESS, 0x4b, 0x01); - wait_ms(10); + wait_us(10000); i2c_mem_write(MAG_ADDRESS, 0x4c, 0x00); - wait_ms(10); + wait_us(10000); i2c_mem_write(MAG_ADDRESS, 0x4c, 0x00); - wait_ms(10); + wait_us(10000); i2c_mem_write(MAG_ADDRESS, 0x4e, 0x84); - wait_ms(10); + wait_us(10000); i2c_mem_write(MAG_ADDRESS, 0x51, 0x04); - wait_ms(10); + wait_us(10000); i2c_mem_write(MAG_ADDRESS, 0x52, 0x16); - wait_ms(10); + wait_us(10000); } - + float test_BMX055::get_mag_x_data() { float x_mag; @@ -321,4 +336,345 @@ return z_mag; -} \ No newline at end of file +} + +//Pressure sensor BME280 + +void test_BMX055::initialize() +{ + //I2C initialization + //i2c.frequency(400000); //400 kHz + //i2c.frequency(100000); //100 kHz + + char cmd[18]; + + cmd[0] = 0xf2; // ctrl_hum + cmd[1] = 0x01; // Humidity oversampling x1 + i2c.write(address, cmd, 2); + + cmd[0] = 0xf4; // ctrl_meas + cmd[1] = 0x27; // Temparature oversampling x1, Pressure oversampling x1, Normal mode + i2c.write(address, cmd, 2); + + cmd[0] = 0xf5; // config + cmd[1] = 0xa0; // Standby 1000ms, Filter off + i2c.write(address, cmd, 2); + + cmd[0] = 0x88; // read dig_T regs + i2c.write(address, cmd, 1); + i2c.read(address, cmd, 6); + + dig_T1 = (cmd[1] << 8) | cmd[0]; + dig_T2 = (cmd[3] << 8) | cmd[2]; + dig_T3 = (cmd[5] << 8) | cmd[4]; + + //DEBUG_PRINT("dig_T = 0x%x, 0x%x, 0x%x\n", dig_T1, dig_T2, dig_T3); + + cmd[0] = 0x8E; // read dig_P regs + i2c.write(address, cmd, 1); + i2c.read(address, cmd, 18); + + dig_P1 = (cmd[ 1] << 8) | cmd[ 0]; + dig_P2 = (cmd[ 3] << 8) | cmd[ 2]; + dig_P3 = (cmd[ 5] << 8) | cmd[ 4]; + dig_P4 = (cmd[ 7] << 8) | cmd[ 6]; + dig_P5 = (cmd[ 9] << 8) | cmd[ 8]; + dig_P6 = (cmd[11] << 8) | cmd[10]; + dig_P7 = (cmd[13] << 8) | cmd[12]; + dig_P8 = (cmd[15] << 8) | cmd[14]; + dig_P9 = (cmd[17] << 8) | cmd[16]; + + //DEBUG_PRINT("dig_P = 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", dig_P1, dig_P2, dig_P3, dig_P4, dig_P5, dig_P6, dig_P7, dig_P8, dig_P9); + + cmd[0] = 0xA1; // read dig_H regs + i2c.write(address, cmd, 1); + i2c.read(address, cmd, 1); + cmd[1] = 0xE1; // read dig_H regs + i2c.write(address, &cmd[1], 1); + i2c.read(address, &cmd[1], 7); + + dig_H1 = cmd[0]; + dig_H2 = (cmd[2] << 8) | cmd[1]; + dig_H3 = cmd[3]; + dig_H4 = (cmd[4] << 4) | (cmd[5] & 0x0f); + dig_H5 = (cmd[6] << 4) | ((cmd[5]>>4) & 0x0f); + dig_H6 = cmd[7]; + + //DEBUG_PRINT("dig_H = 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", dig_H1, dig_H2, dig_H3, dig_H4, dig_H5, dig_H6); +} + +float test_BMX055::getTemperature() +{ + uint32_t temp_raw; + float tempf; + char cmd[4]; + + cmd[0] = 0xfa; // temp_msb + i2c.write(address, cmd, 1); + i2c.read(address, &cmd[1], 3); + + temp_raw = (cmd[1] << 12) | (cmd[2] << 4) | (cmd[3] >> 4); + + int32_t temp; + + temp = + (((((temp_raw >> 3) - (dig_T1 << 1))) * dig_T2) >> 11) + + ((((((temp_raw >> 4) - dig_T1) * ((temp_raw >> 4) - dig_T1)) >> 12) * dig_T3) >> 14); + + t_fine = temp; + temp = (temp * 5 + 128) >> 8; + tempf = (float)temp; + + return (tempf/100.0f); +} + +float test_BMX055::getPressure() +{ + uint32_t press_raw; + float pressf; + char cmd[4]; + + cmd[0] = 0xf7; // press_msb + i2c.write(address, cmd, 1); + i2c.read(address, &cmd[1], 3); + + press_raw = (cmd[1] << 12) | (cmd[2] << 4) | (cmd[3] >> 4); + + int32_t var1, var2; + uint32_t press; + + var1 = (t_fine >> 1) - 64000; + var2 = (((var1 >> 2) * (var1 >> 2)) >> 11) * dig_P6; + var2 = var2 + ((var1 * dig_P5) << 1); + var2 = (var2 >> 2) + (dig_P4 << 16); + var1 = (((dig_P3 * (((var1 >> 2)*(var1 >> 2)) >> 13)) >> 3) + ((dig_P2 * var1) >> 1)) >> 18; + var1 = ((32768 + var1) * dig_P1) >> 15; + if (var1 == 0) { + return 0; + } + press = (((1048576 - press_raw) - (var2 >> 12))) * 3125; + if(press < 0x80000000) { + press = (press << 1) / var1; + } else { + press = (press / var1) * 2; + } + var1 = ((int32_t)dig_P9 * ((int32_t)(((press >> 3) * (press >> 3)) >> 13))) >> 12; + var2 = (((int32_t)(press >> 2)) * (int32_t)dig_P8) >> 13; + press = (press + ((var1 + var2 + dig_P7) >> 4)); + + pressf = (float)press; + return (pressf/100.0f); +} + +float test_BMX055::getHumidity() +{ + uint32_t hum_raw; + float humf; + char cmd[4]; + + cmd[0] = 0xfd; // hum_msb + i2c.write(address, cmd, 1); + i2c.read(address, &cmd[1], 2); + + hum_raw = (cmd[1] << 8) | cmd[2]; + + int32_t v_x1; + + v_x1 = t_fine - 76800; + v_x1 = (((((hum_raw << 14) -(((int32_t)dig_H4) << 20) - (((int32_t)dig_H5) * v_x1)) + + ((int32_t)16384)) >> 15) * (((((((v_x1 * (int32_t)dig_H6) >> 10) * + (((v_x1 * ((int32_t)dig_H3)) >> 11) + 32768)) >> 10) + 2097152) * + (int32_t)dig_H2 + 8192) >> 14)); + v_x1 = (v_x1 - (((((v_x1 >> 15) * (v_x1 >> 15)) >> 7) * (int32_t)dig_H1) >> 4)); + v_x1 = (v_x1 < 0 ? 0 : v_x1); + v_x1 = (v_x1 > 419430400 ? 419430400 : v_x1); + + humf = (float)(v_x1 >> 12); + + return (humf/1024.0f); +} +/* +void test_BMX055::initiate_pres() +{ + + i2c_mem_write(PRES_ADDRESS, CTRL_HUM, 0x01); + i2c_mem_write(PRES_ADDRESS, CONFIG, 0xa0); + + //dig_T1 + int dig_t1_Low = i2c_mem_read(PRES_ADDRESS,DIG_T1_LOW_REGS); + int dig_t1_High = i2c_mem_read(PRES_ADDRESS,DIG_T1_HIGH_REGS); + dig_T1 = uint16_t(dig_t1_Low + 256 * dig_t1_High); + + //dig_T2 + int dig_t2_Low = i2c_mem_read(PRES_ADDRESS, DIG_T2_LOW_REGS); + int dig_t2_High = i2c_mem_read(PRES_ADDRESS, DIG_T2_HIGH_REGS); + dig_T2 = int16_t(dig_t2_Low + 256 * dig_t2_High); + + //dig_T3 + int dig_t3_Low = i2c_mem_read(PRES_ADDRESS, DIG_T3_LOW_REGS); + int dig_t3_High = i2c_mem_read(PRES_ADDRESS, DIG_T3_HIGH_REGS); + dig_T3 = int16_t(dig_t3_Low + 256 * dig_t3_High); + + + //Pressure + + //dig_P1 + int dig_p1_Low = i2c_mem_read(PRES_ADDRESS, DIG_P1_LOW_REGS); + int dig_p1_High = i2c_mem_read(PRES_ADDRESS, DIG_P1_HIGH_REGS); + dig_P1 = uint16_t(dig_p1_Low + 256 * dig_p1_High); + + //dig_P2 + int dig_p2_Low = i2c_mem_read(PRES_ADDRESS, DIG_P2_LOW_REGS); + int dig_p2_High = i2c_mem_read(PRES_ADDRESS, DIG_P2_HIGH_REGS); + dig_P2 = int16_t(dig_p2_Low + 256 * dig_p2_High); + + //dig_P3 + int dig_p3_Low = i2c_mem_read(PRES_ADDRESS, DIG_P3_LOW_REGS); + int dig_p3_High = i2c_mem_read(PRES_ADDRESS, DIG_P3_HIGH_REGS); + dig_P3 = int16_t(dig_p3_Low + 256 * dig_p3_High); + + //dig_P4 + int dig_p4_Low = i2c_mem_read(PRES_ADDRESS, DIG_P4_LOW_REGS); + int dig_p4_High = i2c_mem_read(PRES_ADDRESS, DIG_P4_HIGH_REGS); + dig_P4 = int16_t(dig_p4_Low + 256 * dig_p4_High); + + //dig_P5 + int dig_p5_Low = i2c_mem_read(PRES_ADDRESS, DIG_P5_LOW_REGS); + int dig_p5_High = i2c_mem_read(PRES_ADDRESS, DIG_P5_HIGH_REGS); + dig_P5 = int16_t(dig_p5_Low + 256 * dig_p5_High); + + //dig_P6 + int dig_p6_Low = i2c_mem_read(PRES_ADDRESS, DIG_P6_LOW_REGS); + int dig_p6_High = i2c_mem_read(PRES_ADDRESS, DIG_P6_HIGH_REGS); + dig_P6 = int16_t(dig_p6_Low + 256 * dig_p6_High); + + //dig_P7 + int dig_p7_Low = i2c_mem_read(PRES_ADDRESS, DIG_P7_LOW_REGS); + int dig_p7_High = i2c_mem_read(PRES_ADDRESS, DIG_P7_HIGH_REGS); + dig_P7 = int16_t(dig_p7_Low + 256 * dig_p7_High); + + //dig_P8 + int dig_p8_Low = i2c_mem_read(PRES_ADDRESS, DIG_P8_LOW_REGS); + int dig_p8_High = i2c_mem_read(PRES_ADDRESS, DIG_P8_HIGH_REGS); + dig_P8 = int16_t(dig_p8_Low + 256 * dig_p8_High); + + //dig_P9 + int dig_p9_Low = i2c_mem_read(PRES_ADDRESS, DIG_P9_LOW_REGS); + int dig_p9_High = i2c_mem_read(PRES_ADDRESS, DIG_P9_HIGH_REGS); + dig_P9 = int16_t(dig_p2_Low + 256 * dig_p9_High); + + + //Humid + //dig_H1 + dig_H1 = uint16_t(i2c_mem_read(PRES_ADDRESS, HUD_H1_REGS)); + + //dig_H2 + int dig_h2_Low = i2c_mem_read(PRES_ADDRESS, HUD_H2_LOW_REGS); + int dig_h2_High = i2c_mem_read(PRES_ADDRESS, HUD_H2_HIGH_REGS); + dig_H2 = int16_t(dig_h2_Low + 256 * dig_h2_High); + + //dig_H3 + dig_H3 = uint16_t(i2c_mem_read(PRES_ADDRESS, HUD_H3_REGS)); + + //dig_H4 + int dig_h4_Low = i2c_mem_read(PRES_ADDRESS, HUD_H4_LOW_REGS); + int dig_h4_High = i2c_mem_read(PRES_ADDRESS, HUD_H4_HIGH_REGS); + dig_H4 = int16_t((dig_h4_High << 4) | (dig_h4_Low & 0x0f)); + + //HUD_H5_HIGH_REGS + int dig_h5_High = i2c_mem_read(PRES_ADDRESS, HUD_H5_HIGH_REGS); + dig_H5 = int16_t((dig_h5_High << 4) | ((dig_h4_Low>>4) & 0x0f)); + + //HUD H6 + dig_H6 = int16_t(i2c_mem_read(PRES_ADDRESS, HUD_H6_REGS)); + +} + +float test_BMX055::getTemperature() +{ + uint32_t temp_raw; + float tempf; + + //Tempreture raw data + int temp_XLow = i2c_mem_read(PRES_ADDRESS, TEMP_XLSB); + int temp_Low = i2c_mem_read(PRES_ADDRESS, TEMP_LSB); + int temp_High = i2c_mem_read(PRES_ADDRESS, TEMP_MSB); + + temp_raw = (temp_High << 12) | (temp_Low << 4) | (temp_XLow >> 4); + + int32_t temp; + + temp = + (((((temp_raw >> 3) - (dig_T1 << 1))) * dig_T2) >> 11) + + ((((((temp_raw >> 4) - dig_T1) * ((temp_raw >> 4) - dig_T1)) >> 12) * dig_T3) >> 14); + + t_fine = temp; + temp = (temp * 5 + 128) >> 8; + tempf = (float)temp; + + return (tempf/100.0f); +} + +float test_BMX055::getPressure() +{ + uint32_t press_raw; + float pressf; + + int press_XLow = i2c_mem_read(PRES_ADDRESS, PRES_XLSB); + int press_Low = i2c_mem_read(PRES_ADDRESS, PRES_LSB); + int press_High = i2c_mem_read(PRES_ADDRESS, PRES_MSB); + + press_raw = (press_High << 12) | (press_Low << 4) | (press_XLow >> 4); + + int32_t var1, var2; + uint32_t press; + + var1 = (t_fine >> 1) - 64000; + var2 = (((var1 >> 2) * (var1 >> 2)) >> 11) * dig_P6; + var2 = var2 + ((var1 * dig_P5) << 1); + var2 = (var2 >> 2) + (dig_P4 << 16); + var1 = (((dig_P3 * (((var1 >> 2)*(var1 >> 2)) >> 13)) >> 3) + ((dig_P2 * var1) >> 1)) >> 18; + var1 = ((32768 + var1) * dig_P1) >> 15; + if (var1 == 0) { + return 0; + } + press = (((1048576 - press_raw) - (var2 >> 12))) * 3125; + if(press < 0x80000000) { + press = (press << 1) / var1; + } else { + press = (press / var1) * 2; + } + var1 = ((int32_t)dig_P9 * ((int32_t)(((press >> 3) * (press >> 3)) >> 13))) >> 12; + var2 = (((int32_t)(press >> 2)) * (int32_t)dig_P8) >> 13; + press = (press + ((var1 + var2 + dig_P7) >> 4)); + + pressf = (float)press; + return (pressf/100.0f); +} + +float test_BMX055::getHumidity() +{ + uint32_t hum_raw; + float humf; + + int hud_Low = i2c_mem_read(PRES_ADDRESS, HUM_LSB); + int hud_High = i2c_mem_read(PRES_ADDRESS, HUM_MSB); + + hum_raw = (hud_High << 8) | hud_Low; + + int32_t v_x1; + + v_x1 = t_fine - 76800; + v_x1 = (((((hum_raw << 14) -(((int32_t)dig_H4) << 20) - (((int32_t)dig_H5) * v_x1)) + + ((int32_t)16384)) >> 15) * (((((((v_x1 * (int32_t)dig_H6) >> 10) * + (((v_x1 * ((int32_t)dig_H3)) >> 11) + 32768)) >> 10) + 2097152) * + (int32_t)dig_H2 + 8192) >> 14)); + v_x1 = (v_x1 - (((((v_x1 >> 15) * (v_x1 >> 15)) >> 7) * (int32_t)dig_H1) >> 4)); + v_x1 = (v_x1 < 0 ? 0 : v_x1); + v_x1 = (v_x1 > 419430400 ? 419430400 : v_x1); + + humf = (float)(v_x1 >> 12); + + return (humf/1024.0f); +} +*/ \ No newline at end of file
diff -r 3df2d4d2d393 -r b387585de3b5 test_BMX055.h --- a/test_BMX055.h Sat May 23 13:17:09 2020 +0000 +++ b/test_BMX055.h Sat Jul 25 11:02:21 2020 +0000 @@ -4,6 +4,8 @@ #define ACC_ADDRESS 0x19 #define MAG_ADDRESS 0x13 +#define PRES_ADDRESS 0x76 + #define MAG_SOFT_RESET 0x4B #define MAG_ENEBLE 0x4E @@ -32,12 +34,69 @@ #define GYRO_RANGE_SET 0x0f #define ACC_RANGE_SET 0x0f + +#define CTRL_HUM 0xf2 +#define CTRL_MEAS 0xf4 +#define CONFIG 0xf5 + +#define DIG_T1_LOW_REGS 0x88 // read dig_T1 regs +#define DIG_T1_HIGH_REGS 0x89 // read dig_T1 regs +#define DIG_T2_LOW_REGS 0x8a // read dig_T2 regs +#define DIG_T2_HIGH_REGS 0x8b // read dig_T2 regs +#define DIG_T3_LOW_REGS 0x8c // read dig_T3 regs +#define DIG_T3_HIGH_REGS 0x8d // read dig_T3 regs + +#define DIG_P1_LOW_REGS 0x8e // read dig_P1 regs +#define DIG_P1_HIGH_REGS 0x8f // read dig_P1 regs +#define DIG_P2_LOW_REGS 0x90 // read dig_P2 regs +#define DIG_P2_HIGH_REGS 0x91 // read dig_P2 regs +#define DIG_P3_LOW_REGS 0x92 // read dig_P3 regs +#define DIG_P3_HIGH_REGS 0x93 // read dig_P3 regs +#define DIG_P4_LOW_REGS 0x94 // read dig_P4 regs +#define DIG_P4_HIGH_REGS 0x95 // read dig_P4 regs +#define DIG_P5_LOW_REGS 0x96 // read dig_P5 regs +#define DIG_P5_HIGH_REGS 0x97 // read dig_P5 regs +#define DIG_P6_LOW_REGS 0x98 // read dig_P6 regs +#define DIG_P6_HIGH_REGS 0x99 // read dig_P6 regs +#define DIG_P7_LOW_REGS 0x9a // read dig_P7 regs +#define DIG_P7_HIGH_REGS 0x9b // read dig_P7 regs +#define DIG_P8_LOW_REGS 0x9c // read dig_P8 regs +#define DIG_P8_HIGH_REGS 0x9d // read dig_P8 regs +#define DIG_P9_LOW_REGS 0x9e // read dig_P9 regs +#define DIG_P9_HIGH_REGS 0x9f // read dig_P9 regs + +#define HUD_H1_REGS 0xA1 // read dig_H1 regs +#define HUD_H2_LOW_REGS 0xe1 // read dig_H2 regs +#define HUD_H2_HIGH_REGS 0xe2 // read dig_H2 regs +#define HUD_H3_REGS 0xe3 // read dig_H3 regs +#define HUD_H4_LOW_REGS 0xe5 // read dig_H4 regs and HIGh of H5 +#define HUD_H4_HIGH_REGS 0xe4 // read dig_H4 regs +#define HUD_H5_HIGH_REGS 0xe6 // read dig_H5 regs +#define HUD_H6_REGS 0xe7 // read dig_H6 regs + +#define TEMP_MSB 0xFa +#define TEMP_LSB 0xFb +#define TEMP_XLSB 0xFc + +#define PRES_MSB 0xF7 +#define PRES_LSB 0xF8 +#define PRES_XLSB 0xF9 + +#define HUM_MSB 0xFd +#define HUM_LSB 0xFe + class test_BMX055 { public: - test_BMX055(PinName sda,PinName scl); +/* +test_BMX055::test_BMX055(PinName sda,PinName scl, char slave_adr):i2c(sda ,scl),address(slave_adr){ +*/ + //test_BMX055(PinName sda,PinName scl, char slave_adr); + //~test_BMX055(); + + test_BMX055(I2C &i2c_obj, char slave_adr); ~test_BMX055(); - + void i2c_mem_write(int device_address, int mem_address, int mem_data); int i2c_mem_read(int device_address, int mem_address); @@ -58,15 +117,47 @@ float get_mag_x_data(void); float get_mag_y_data(void); float get_mag_z_data(void); - + + + //void initiate_pres(void); + void initialize(void); + /** Read the current temperature value (degree Celsius) from BME280 sensor + * + */ + float getTemperature(void); + + /** Read the current pressure value (hectopascal)from BME280 sensor + * + */ + float getPressure(void); + + /** Read the current humidity value (humidity %) from BME280 sensor + * + */ + float getHumidity(void); + + private: - I2C i2c; + //I2C i2c; int currentAcceleroRange; int currentGyroRange; float gyro_scale_factor; int acc_scale_factor; float gravity; float RAD_TO_DEG; + + I2C *i2c_p; + I2C &i2c; + + char address; + uint16_t dig_T1; + int16_t dig_T2, dig_T3; + uint16_t dig_P1; + int16_t dig_P2, dig_P3, dig_P4, dig_P5, dig_P6, dig_P7, dig_P8, dig_P9; + uint16_t dig_H1, dig_H3; + int16_t dig_H2, dig_H4, dig_H5, dig_H6; + int32_t t_fine; + }; \ No newline at end of file