Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

Disabling the temp sensor on the BMP388
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Disabling the temp sensor on the BMP388

by LRF on Fri Oct 22, 2021 1:17 pm

Could someone tell me what the proper wording of a line of code to disable the temperature part so the BMP388 would only read pressure? I know this is possible per the datasheet but just not exactly sure what the code would be to do this.
Thanks in advance for your help

LRF
 
Posts: 14
Joined: Mon Sep 09, 2019 10:02 am

Re: Disabling the temp sensor on the BMP388

by LRF on Sun Oct 24, 2021 5:45 pm

I have spent considerable time time weekend reviewing the files of the Adafruit_BMP3XX library and it does seem to reference modifications to sensor register 0x01B but I think the only lines of code would only start the temp sensor which is already on when you start the sensor. I want to turn it off.
Arduino_bmp3 library has a method to do this thru a function called .modify(). I want to use the Adafruit library but unless I can find a way I will have to rewrite to the other library.

If you can see what I may be missing please let me know. Thanks

LRF
 
Posts: 14
Joined: Mon Sep 09, 2019 10:02 am

Re: Disabling the temp sensor on the BMP388

by LRF on Tue Oct 26, 2021 8:55 am

We are still trying to use the Adafruit library but so far with out success. We wrote the following code which should have read the status of the sensor register 0x1B, "pwr_ctrl" and then changed bit 1 to a zero value which should have turned off the temp sensor part of the BMP388:

The following is a code snippet that we modified from the library example code "bmp3xx_simpletest.ino":
Added code is in bold

"// Set up oversampling and filter initialization
bmp.setTemperatureOversampling(BMP3_OVERSAMPLING_8X);
bmp.setPressureOversampling(BMP3_OVERSAMPLING_4X);
bmp.setIIRFilterCoeff(BMP3_IIR_FILTER_COEFF_3);
bmp.setOutputDataRate(BMP3_ODR_50_HZ);;

uint8_t reg_addr = BMP3_REG_PWR_CTRL;
uint8_t reg_data;;

bmp3_get_regs(reg_addr, &reg_data, 1, &bmp.the_sensor);
//reset bit 1
reg_data &= ~(1 << 1);
bmp3_set_regs(&reg_addr, &reg_data, 1, &bmp.the_sensor);
"

As written it would not compile and the issue was &bmp.the_sendor. Further investigation showed that the struct for the device was defined as "private" in the .h file Adafruit_3XX.h. So we made the following changes moving the struct statement from "private" to "public". hear is the snippet of the changes.

" /// Pressure (Pascals) assigned after calling performReading()
double pressure;

//The next line was moved from the "private" section below to this "public" section
//this was done so that we could turn the Temp Sensor off. See bmp3xx_simpletest.ino
struct bmp3_dev the_sensor;


private:
Adafruit_I2CDevice *i2c_dev = NULL; ///< Pointer to I2C bus interface
Adafruit_SPIDevice *spi_dev = NULL; ///< Pointer to SPI bus interface

bool _init(void);

bool _filterEnabled, _tempOSEnabled, _presOSEnabled, _ODREnabled;
uint8_t _i2caddr;
int32_t _sensorID;
int8_t _cs;
unsigned long _meas_end;

uint8_t spixfer(uint8_t x);
//The following line has been commented out and a copy of it placed in the "public" section. See above
//struct bmp3_dev the_sensor;"


After this change our code does compile and runs, however the value returned from register 0x1B is zero when it should be something like "00110011" (51) and after the change "00110001" (49).

I am looking for suggestions of what may be wrong here and how can I correct. One question I have is 1st: Why was the struct of the device in private and did moving its locattion to "public" have some unintended results?

BTW, with our changes in place and when the program continues on to the Loop portion it runs perfect return both temp and pressure results. So our code didn't seem to have any adverse results.

LRF
 
Posts: 14
Joined: Mon Sep 09, 2019 10:02 am

Re: Disabling the temp sensor on the BMP388

by LRF on Tue Oct 26, 2021 3:39 pm

I believe this issue has been solved. I have deleted all the code in my last posting from my program as it clearly was not the solution.
The solution existed in the .CPP file and was part of the original Bosch library but when Adafruit wrote their wrapper they decided to not create functions for all the option possibilities. :(
We made a couple changes to the .CPP file and now the temperature sensor is disabled. Which was the mission.

LRF
 
Posts: 14
Joined: Mon Sep 09, 2019 10:02 am

Please be positive and constructive with your questions and comments.