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 CalibrationData.dig_T1 = ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_T1); CalibrationData.dig_T2 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_T2); CalibrationData.dig_T3 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_T3); // Read presure calibration data CalibrationData.dig_P1 = ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P1); CalibrationData.dig_P2 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P2); CalibrationData.dig_P3 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P3); CalibrationData.dig_P4 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P4); CalibrationData.dig_P5 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P5); CalibrationData.dig_P6 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P6); CalibrationData.dig_P7 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P7); CalibrationData.dig_P8 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P8); CalibrationData.dig_P9 = ReadInt16_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 }; // Check the device signature bmp280.WriteRead(WriteBuffer, ReadBuffer); Debug.WriteLine("BMP280 Signature: " + ReadBuffer[0].ToString()); if (ReadBuffer[0] != BMP280_Signature) { Debug.WriteLine("BMP280::begin Signature MISMATCH!!!!!!!!!!!!!!!!!"); return; } Init = true; // read the coefficients table CalibrationData = await ReadCoefficeints(); // Write control register await WriteControlRegister(0x3F); // write humidity control register await WriteControlRegisterHumidity(0x03); }
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 CalibrationData.dig_T1 = ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_T1); CalibrationData.dig_T2 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_T2); CalibrationData.dig_T3 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_T3); // Read presure calibration data CalibrationData.dig_P1 = ReadUInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P1); CalibrationData.dig_P2 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P2); CalibrationData.dig_P3 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P3); CalibrationData.dig_P4 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P4); CalibrationData.dig_P5 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P5); CalibrationData.dig_P6 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P6); CalibrationData.dig_P7 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P7); CalibrationData.dig_P8 = ReadInt16_LittleEndian((byte)eRegisters.BMP280_REGISTER_DIG_P8); CalibrationData.dig_P9 = ReadInt16_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 }; // Check the device signature bmp280.WriteRead(WriteBuffer, ReadBuffer); Debug.WriteLine("BMP280 Signature: " + ReadBuffer[0].ToString()); if (ReadBuffer[0] != BMP280_Signature) { Debug.WriteLine("BMP280::begin Signature MISMATCH!!!!!!!!!!!!!!!!!"); return; } Init = true; // read the coefficients table CalibrationData = await ReadCoefficeints(); // Write control register await WriteControlRegister(0x3F); // write humidity control register await WriteControlRegisterHumidity(0x03); }