public bool TestConnection() { if (_i2c.ReadBytes(HMC5883L_RA_ID_A, 3, _buffer) == 3) { return(_buffer[0] == 'H' && _buffer[1] == '4' && _buffer[2] == '3'); } return(false); }
private int GetReadingFromConverter(ushort config) { // Write config register to the ADC var pointerCommand = (new[] { (byte)ADS1015_REG_POINTER_CONFIG.GetHashCode() }).Union(BitConverter.GetBytes(config)).ToArray(); _ads1115.Write((byte)ADS1015_REG_POINTER_CONFIG, BitConverter.GetBytes(config)); //_ads1115.Write(pointerCommand); var dataBuffer = new byte[2]; Task.Delay(TimeSpan.FromMilliseconds(ADS1115_CONVERSIONDELAY.GetHashCode())).Wait(); //pointerCommand = new[] { (byte)ADS1015_REG_POINTER_CONVERT.GetHashCode() }; _ads1115.ReadBytes((byte)ADS1015_REG_POINTER_CONVERT, (byte)dataBuffer.Length, dataBuffer); //_ads1115.WriteRead(pointerCommand, dataBuffer); // Read the conversion results var rawReading = dataBuffer[0] << 8 | dataBuffer[1]; return(rawReading); }