Beispiel #1
0
        //Method to read the caliberation data from the registers
        private async Task <Bmp280CalibrationData> ReadCoefficeintsAsync()
        {
            // 16 bit calibration data is stored as Little Endian, the helper method will do the byte swap.
            _calibrationData = new Bmp280CalibrationData
            {
                DigT1 = ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigT1),
                DigT2 = (short)ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigT2),
                DigT3 = (short)ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigT3),
                DigP1 = ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP1),
                DigP2 = (short)ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP2),
                DigP3 = (short)ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP3),
                DigP4 = (short)ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP4),
                DigP5 = (short)ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP5),
                DigP6 = (short)ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP6),
                DigP7 = (short)ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP7),
                DigP8 = (short)ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP8),
                DigP9 = (short)ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP9)
            };

            // Read temperature calibration data

            // Read presure calibration data

            await Task.Delay(1);

            return(_calibrationData);
        }
Beispiel #2
0
        private async Task BeginAsync()
        {
            Debug.WriteLine("BMP280::Begin");
            byte[] writeBuffer = { (byte)ERegisters.Bmp280RegisterChipid };
            byte[] readBuffer  = { 0xFF };

            //Read the device signature
            _bmp280.WriteRead(writeBuffer, readBuffer);
            Debug.WriteLine("BMP280 Signature: " + readBuffer[0]);

            //Verify the device signature
            if (readBuffer[0] != Bmp280Signature)
            {
                Debug.WriteLine("BMP280::Begin Signature Mismatch.");
                return;
            }

            //Set the initalize variable to true
            _init = true;

            //Read the coefficients table
            _calibrationData = await ReadCoefficeintsAsync();

            //Write control register
            await WriteControlRegisterAsync();

            //Write humidity control register
            await WriteControlRegisterHumidityAsync();
        }
Beispiel #3
0
        //Method to read the caliberation data from the registers
        private async Task<Bmp280CalibrationData> ReadCoefficeintsAsync()
        {
            // 16 bit calibration data is stored as Little Endian, the helper method will do the byte swap.
            _calibrationData = new Bmp280CalibrationData
            {
                DigT1 = ReadUInt16_LittleEndian((byte) ERegisters.Bmp280RegisterDigT1),
                DigT2 = (short) ReadUInt16_LittleEndian((byte) ERegisters.Bmp280RegisterDigT2),
                DigT3 = (short) ReadUInt16_LittleEndian((byte) ERegisters.Bmp280RegisterDigT3),
                DigP1 = ReadUInt16_LittleEndian((byte) ERegisters.Bmp280RegisterDigP1),
                DigP2 = (short) ReadUInt16_LittleEndian((byte) ERegisters.Bmp280RegisterDigP2),
                DigP3 = (short) ReadUInt16_LittleEndian((byte) ERegisters.Bmp280RegisterDigP3),
                DigP4 = (short) ReadUInt16_LittleEndian((byte) ERegisters.Bmp280RegisterDigP4),
                DigP5 = (short) ReadUInt16_LittleEndian((byte) ERegisters.Bmp280RegisterDigP5),
                DigP6 = (short) ReadUInt16_LittleEndian((byte) ERegisters.Bmp280RegisterDigP6),
                DigP7 = (short) ReadUInt16_LittleEndian((byte) ERegisters.Bmp280RegisterDigP7),
                DigP8 = (short) ReadUInt16_LittleEndian((byte) ERegisters.Bmp280RegisterDigP8),
                DigP9 = (short) ReadUInt16_LittleEndian((byte) ERegisters.Bmp280RegisterDigP9)
            };

            // Read temperature calibration data

            // Read presure calibration data

            await Task.Delay(1);
            return _calibrationData;
        }
Beispiel #4
0
        private async Task BeginAsync()
        {
            Debug.WriteLine("BMP280::Begin");
            byte[] writeBuffer = {(byte) ERegisters.Bmp280RegisterChipid};
            byte[] readBuffer = {0xFF};

            //Read the device signature
            _bmp280.WriteRead(writeBuffer, readBuffer);
            Debug.WriteLine("BMP280 Signature: " + readBuffer[0]);

            //Verify the device signature
            if (readBuffer[0] != Bmp280Signature)
            {
                Debug.WriteLine("BMP280::Begin Signature Mismatch.");
                return;
            }

            //Set the initalize variable to true
            _init = true;

            //Read the coefficients table
            _calibrationData = await ReadCoefficeintsAsync();

            //Write control register
            await WriteControlRegisterAsync();

            //Write humidity control register
            await WriteControlRegisterHumidityAsync();
        }