示例#1
0
        // Method to read the caliberation data from the registers
        private async Task <Bmp280CalibrationData> ReadCoefficeints()
        {
            // 16 bit calibration data is stored as Little Endian, the helper method will do the byte swap.
            this.calibrationData = new Bmp280CalibrationData();

            // Read temperature calibration data
            this.calibrationData.DigT1 = this.ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigT1);
            this.calibrationData.DigT2 = (short)this.ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigT2);
            this.calibrationData.DigT3 = (short)this.ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigT3);

            // Read presure calibration data
            this.calibrationData.DigP1 = this.ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP1);
            this.calibrationData.DigP2 = (short)this.ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP2);
            this.calibrationData.DigP3 = (short)this.ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP3);
            this.calibrationData.DigP4 = (short)this.ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP4);
            this.calibrationData.DigP5 = (short)this.ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP5);
            this.calibrationData.DigP6 = (short)this.ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP6);
            this.calibrationData.DigP7 = (short)this.ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP7);
            this.calibrationData.DigP8 = (short)this.ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP8);
            this.calibrationData.DigP9 = (short)this.ReadUInt16_LittleEndian((byte)ERegisters.Bmp280RegisterDigP9);

            await Task.Delay(1);

            return(this.calibrationData);
        }
示例#2
0
        private async Task Begin()
        {
            Console.WriteLine("BMP280::Begin");

            // Read the device signature
            this.i2CBus.WriteCommand(Bmp280Address, (byte)ERegisters.Bmp280RegisterChipid);
            var buffer = this.i2CBus.ReadBytes(Bmp280Address, 1);

            Console.WriteLine("BMP280 Signature: " + buffer[0].ToString());

            // Set the initalize variable to true
            this.init = true;

            // Read the coefficients table
            this.calibrationData = await this.ReadCoefficeints();

            // Write control register
            await this.WriteControlRegister();

            // Write humidity control register
            await this.WriteControlRegisterHumidity();
        }