private double?GetTemperature() { _device.SendCommand(true, 100, 0xB4); _device.SendCommand(true, 100, 0xB8, 0x00); var data = _device.ReadData(8, ReadScratchpadCommand, 0x00); var Temp = 0.0; if (GetBit(data[2], 8)) { // Negative Temperature var TempWhole = ~data[2]; var TempFrac = ((~data[1]) & 0xF8) * (2 ^ -8); Temp = -1 * (TempWhole + TempFrac); } else { // Positive Temperature var TempWhole = data[2]; var TempFrac = (data[1] & 0xF8) * (2 ^ -8); Temp = data[2] + TempFrac; } var vdd = ((data[3] + data[4] * 0xFF) & 0x3FF) * 0.01; var vdd2 = ((data[5] + data[6] * 0xFF) & 0x3FF) * 0.01; return(0.0); }
public double?GetTemperature() { _device.SendCommand(true, 500, ConvertTCommand); var data = _device.ReadData(9, ReadScratchpadCommand); var value = false; foreach (var b in data.Where(b => b != 255)) { value = true; } if (!value) { return(null); } return(GetTemp_Read(data[TemperatureMsb], data[TemperatureLsb])); }