finitespace / BME280

Provides an Arduino library for reading and interpreting Bosch BME280 data over I2C, SPI or Sw SPI.
GNU General Public License v3.0
212 stars 105 forks source link

Return individual trimming parameters. #99

Closed Bolukan closed 4 years ago

Bolukan commented 6 years ago

Related issue # and issue behavior

Issue #98: I would like to fingerprint each BME280 using the hash of the individual trimming parameters. I need a function that returns a copy of uint8_t m_dig[32].

Description of changes/fixes

The receiving array has to be supplied by reference. The function returns the reference to this array too (so not void, see below an example).

@mention a person to review

@finitespace, please comment.

Alternative was to return a struct. The advantage would be the parameters (dig_T1 - dig_T3, dig_P1 - dig_P9 and dig_H1 - dig_H6) could be added. But I don't need them now, so I prefer keeping it simple.

Steps to test

uint8_t parameters[32];
CRC32 crc;
uint32_t checksum = CRC32::calculate(bme.compensationParameters(parameters), 32);

Serial.printf("SensorID: 0x%08X\nHash(CRC32) of ", checksum);  
for (int i=0; i<32; i++) Serial.printf("%02X ", parameters[i]);  
Serial.print("\n");

Any outstanding TODOs or known issues

Adding an example (WIP)

Bolukan commented 4 years ago

Better to implement the unique BME Id