Assistance greatly appreciated in calculating temperature
Closed this issue · 1 comments
Hi all,
I've spent a couple of days trying to get correct temperature data out of a DPS310 on custom hardware, to seemingly no avail - and would greatly appreciate some input.
Background:
- Custom hardware
- Communication with DPS310 is via SPI, at 8MHz, good waveforms confirmed on scope etc
- SPI host is a 32-bit Microchip SAM MCU, 6 other SPI devices on the slave all communicating and working as expected
- Good comms with device confirmed with a good readback of both REV_ID and PROD_ID
- Device soft resets OK, and reads back the coefs OK. My coefs appear to have been read and reconstructed correctly by our driver, as they are almost identical to other users coefs (such as found here #23). My coefs are below.
coefs
c0 222
c1 -297
c00 79832
c10 -56308
c01 -2295
c11 1444
c20 -9701
c21 111
c30 -1289
- I have the DPS310 configured for no oversampling (i.e. TMP_PRC default), so my Kt is 524288.
- DPS310 device and PCB confirmed at 25.7degC with calibrated thermal camera and contact temperature measurement
I'm reading Traw as 200498.
So following the datasheet - Traw_sc = Traw/kT = 200498/524288 = 0.382419
Tcomp = (c0 * 0.5)+(c1 * Traw_sc) = 111+(-113.578443) = ~(-2.57)degC.
I've run the calculation as above, outside of the driver to simply try and understand where I'm going wrong with the calculation, rather than any type errors/type conversion errors in the driver, as I think the problem is with my understanding of how to calculate the temperature, rather than the driver per se.
For example, using the values from @tmanaud in the thread I linked to earlier, I get 99.07degC - though I've no idea if that temp is correct as the post does not state the temperature.
Really hoping somebody can point me in the right direction. Many thanks!
Closing this issue, as the problem is resolved.
I was not reading the TMP_CFG.TMP_EXT bit, and was reading from the internal sensor (0), rather than the external sensor (1) as indicated by TMP_COEF_SRCE. Temperature readings are now within 0.1degC of expected values.