02-07-2024 11:05 PM
Hello.
I have a PCB with a BMP280 connected via SPI to a ESP32. I am using also the API in https://github.com/BoschSensortec/BMP2-Sensor-API.
I have managed to read the temperature correctly, but I didn't get it with the pressure:
Data[0]: Temperature: 22.1783 deg C Pressure: 110000.0000 Pa
Apparently I am able to read the registers 0x7F and the 5 next with the following results:
I (9107571) BMP280: bmp2_get_sensor_data result: 4
Data[0]: Temperature: 22.1783 deg C Pressure: 110000.0000 Pa
----- BEGIN READ -----
READ -- length = 6
READ -- reg_addr = f7
READ -- rx_buffer[0] = 77 4d
READ -- rx_buffer[1] = 86 56
READ -- rx_buffer[2] = 160 a0
READ -- rx_buffer[3] = 125 7d
READ -- rx_buffer[4] = 220 dc
READ -- rx_buffer[5] = 129 81
From this point I don't know what am I doing wrong. The values 4d 56 a0 are parsed to the compensate_pressure API function, that has some intimidating maths. The output from this function is this BMP2_MAX_PRES_DOUBLE.
Can you help me to find what am I doing wrong?
Thanks!
02-19-2024 04:00 AM
Hi opobla,
Did you strictly refer to BMP280 example code on Github?
02-19-2024 02:25 PM
Hi BSTRobin.
I am not sure to understand your question. I am using the API for your github repository. According to this, I have to fill a `bmp2_dev` structure with a function to read from SPI, to write, to delay. Then I can use `bmp2_get_sensor_data` to read the pressure and the temperature.
The problem that I have is that call `bmp2_get_sensor_data`, the function returns with an error code BMP2_MAX_PRES_DOUBLE.
In my previous message I showed the values that the SPI read function is returning while reading the F7 register and the sucessive +6, in case that might help to diagnose the problem.
02-20-2024 11:50 PM
Just to give more information, here is the dump of the calibration data that I am getting from the device:
READ -- length = 25
READ -- reg_addr = 88
READ -- rx_buffer[0] = 218 da
READ -- rx_buffer[1] = 105 69
READ -- rx_buffer[2] = 9 9
READ -- rx_buffer[3] = 101 65
READ -- rx_buffer[4] = 220 dc
READ -- rx_buffer[5] = 129 81
READ -- rx_buffer[6] = 251 fb
READ -- rx_buffer[7] = 63 3f
READ -- rx_buffer[8] = 12 c
READ -- rx_buffer[9] = 107 6b
READ -- rx_buffer[10] = 252 fc
READ -- rx_buffer[11] = 63 3f
READ -- rx_buffer[12] = 203 cb
READ -- rx_buffer[13] = 148 94
READ -- rx_buffer[14] = 1 1
READ -- rx_buffer[15] = 0 0
READ -- rx_buffer[16] = 220 dc
READ -- rx_buffer[17] = 129 81
READ -- rx_buffer[18] = 251 fb
READ -- rx_buffer[19] = 63 3f
READ -- rx_buffer[20] = 220 dc
READ -- rx_buffer[21] = 129 81
READ -- rx_buffer[22] = 251 fb
READ -- rx_buffer[23] = 63 3f
READ -- rx_buffer[24] = 28 1c
Do they make sense? I am comparing these values with the one given as an example in the datasheet (page 23) and they are significantly different.
On the other hand, the value that I am getting as uncompensated pressure reading is 347984, and it changes when pressure changes, so I guess that the problem is with the compensating algorithm.