//Method to read the caliberation data from the registers private async Task <BMP280_CalibrationData> ReadCoefficeints() { // 16 bit calibration data is stored as Little Endian, the helper method will do the byte swap. CalibrationData = new BMP280_CalibrationData { // Read temperature calibration data Dig_T1 = ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_T1), Dig_T2 = (Int16)ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_T2), Dig_T3 = (Int16)ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_T3), // Read presure calibration data Dig_P1 = ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P1), Dig_P2 = (Int16)ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P2), Dig_P3 = (Int16)ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P3), Dig_P4 = (Int16)ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P4), Dig_P5 = (Int16)ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P5), Dig_P6 = (Int16)ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P6), Dig_P7 = (Int16)ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P7), Dig_P8 = (Int16)ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P8), Dig_P9 = (Int16)ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P9) }; await Task.Delay(1); return(CalibrationData); }
private async Task Begin() { Debug.WriteLine("BMP280::Begin"); byte[] WriteBuffer = new byte[] { (byte)eRegisters.BMP280_REGISTER_CHIPID }; byte[] ReadBuffer = new byte[] { 0xFF }; //Read the device signature bmp280.WriteRead(WriteBuffer, ReadBuffer); Debug.WriteLine("BMP280 ID: " + ReadBuffer[0].ToString()); //Verify the device signature if (ReadBuffer[0] != BMP280_Signature) { Debug.WriteLine("BMP280::Begin Signature Mismatch."); return; } //Set the initalize variable to true init = true; //Read the coefficients table CalibrationData = await ReadCoefficeints(); //Write control register await WriteControlRegister(); //Write humidity control register await WriteControlRegisterHumidity(); }