public void CalculationWithSampleValues() { Bmp280 sensor = new Bmp280(_i2cDevice); sensor.TemperatureSampling = Sampling.HighResolution; sensor.TryReadTemperature(out Temperature temperature); Assert.Equal(25.08, temperature.DegreesCelsius, 2); sensor.TryReadPressure(out Pressure pressure); Assert.Equal(100653.27, pressure.Pascals, 2); sensor.Dispose(); }
/// <summary> /// Closes the data logger. /// </summary> public void Close() { clock.Ticked -= Clock_Ticked; airTempSensor?.Dispose(); relHumSensor?.Dispose(); staPresSensor?.Dispose(); satellite?.Dispose(); rainfallSensor?.Dispose(); if (loggingThread != null) { loggingThread?.Join(); } IsOpen = false; }
private static void TestI2c(ArduinoBoard board) { var device = board.CreateI2cDevice(new I2cConnectionSettings(0, Bmp280.DefaultI2cAddress)); var bmp = new Bmp280(device); bmp.StandbyTime = StandbyTime.Ms250; bmp.SetPowerMode(Bmx280PowerMode.Normal); Console.WriteLine("Device open"); while (!Console.KeyAvailable) { bmp.TryReadTemperature(out var temperature); bmp.TryReadPressure(out var pressure); Console.Write($"\rTemperature: {temperature.DegreesCelsius:F2}°C. Pressure {pressure.Hectopascals:F1} hPa "); Thread.Sleep(100); } bmp.Dispose(); device.Dispose(); Console.ReadKey(); Console.WriteLine(); }