【发布时间】:2016-09-30 15:43:06
【问题描述】:
我正在尝试从 Windows IoT Core 上的 Bosch BME280 读取数据。我能够重置芯片,读取芯片 ID,获取微调值并读取温度/压力/嗡嗡声值(突发模式)。但是,补偿值不正确。这是我现在得到的值。我希望有人可以分享一些我可以用来比较的价值观。将在后续发布代码。谢谢。
DT1 0x196e,DT2 0x7e66,DT3 0x3200 DP1 0xc78f、DP2 0xded5、DP3 0xd00b、DP4 0xae1b、DP5 0xf00、DP6 0xf9ff、DP7 0xac26、DP8 0xad8、DP9 0xbd10 DH1 0x4b、DH2 0x6d01、DH3 0x0、DH4 0x1308、DH5 0x800、DH6 0x1e 原始温度:0x7fd10,原始压力:0x581bc,原始湿度:0x6cca
这里的补偿值: BME280:温度:187.36c 压力:1344.55 毫巴 湿度:100 %rH
我确信我只是在做一些愚蠢的事情,只需要在正确的方向上稍微推动一下。谢谢。
命令的定义和我读取修剪值的方式。 (仅以 temp 为例)
public static class BME280Commands
{
public static byte[] ChipID = {0xD0 };
public static byte[] Version = { 0xD1 };
public static byte[] SoftReset = { 0xE0, 0xB6 };
public static byte[] ControlHumidity = { 0xF2, 0x04 }; // second parm was 0x01
public static byte[] Status = { 0xF3 };
public static byte[] Control = { 0xF4, 0x91 }; // second parm was 0x87
public static byte[] Control1 = { 0xf4, 0x3f };
public static byte[] Config = { 0xF5, 0x16 };
public static byte[] PressureData = { 0xF7 };
public static byte[] TemperatureData = { 0xFA };
public static byte[] HumidityData = { 0xFD };
public static byte[] DIG_T1 = { 0x88 };
public static byte[] DIG_T2 = { 0x8A };
public static byte[] DIG_T3 = { 0x8C };
public static byte[] DIG_P1 = { 0x8E };
public static byte[] DIG_P2 = { 0x90 };
public static byte[] DIG_P3 = { 0x92 };
public static byte[] DIG_P4 = { 0x94 };
public static byte[] DIG_P5 = { 0x96 };
public static byte[] DIG_P6 = { 0x98 };
public static byte[] DIG_P7 = { 0x9A };
public static byte[] DIG_P8 = { 0x9C };
public static byte[] DIG_P9 = { 0x9E };
public static byte[] DIG_H1 = { 0xA1 };
public static byte[] DIG_H2 = { 0xE1 };
public static byte[] DIG_H3 = { 0xE3 };
public static byte[] DIG_H4 = { 0xE4 };
public static byte[] DIG_H5 = { 0xE5 };
public static byte[] DIG_H6 = { 0xE7 };
public static byte ExpectedChipId = 0x60;
public static byte SlaveAddress = 0x77;
public static byte SoftResetCode = 0xb6;
public Configure()
{
var data = new byte[1];
bme280Sensor.WriteRead(BME280Commands.SoftReset, data);
bme280Sensor.WriteRead(BME280Commands.ChipID, Id);
if (Id[0] == BME280Commands.ExpectedChipId)
{ // How I read the trimming values
bme280Sensor.WriteRead(BME280Commands.DIG_T1, buf2);
_digT1 = (UInt32)((buf2[0] << 8) | buf2[1]);
bme280Sensor.WriteRead(BME280Commands.DIG_T2, buf2);
_digT2 = ((buf2[0] << 8) | buf2[1]);
bme280Sensor.WriteRead(BME280Commands.DIG_T3, buf2);
_digT3 = ((buf2[0] << 8) | buf2[1]);
}
}
我如何读取实际值
var buf8 = new byte[8];
bme280Sensor.Write(BME280Commands.ControlHumidity);
bme280Sensor.Write(BME280Commands.Control);
bme280Sensor.WriteRead(BME280Commands.PressureData, buf8);
_rawPress = (buf8[0] << 16 | buf8[1] << 8 | buf8[2]) >> 4;
_rawTemp = (buf8[3] << 16 | buf8[4] << 8 | buf8[5]) >> 4;
_rawHumid = (buf8[6] << 8) | buf8[7];
【问题讨论】:
标签: windows iot i2c windowsiot