Пример #1
0
 public static void Main(string[] args)
 {
     using (var th = new Hts221(CreateI2cDevice()))
     {
         while (true)
         {
             Console.WriteLine($"Temperature: {th.Temperature}C   Humidity: {th.Humidity}%rH");
             Thread.Sleep(1000);
         }
     }
 }
Пример #2
0
        public static void Main(string[] args)
        {
            using (var th = new Hts221(CreateI2cDevice()))
            {
                while (true)
                {
                    var tempValue = th.Temperature;
                    var humValue  = th.Humidity;

                    Console.WriteLine($"Temperature: {tempValue.DegreesCelsius:0.#}\u00B0C");
                    Console.WriteLine($"Relative humidity: {humValue:0.#}%");

                    // WeatherHelper supports more calculations, such as saturated vapor pressure, actual vapor pressure and absolute humidity.
                    Console.WriteLine($"Heat index: {WeatherHelper.CalculateHeatIndex(tempValue, humValue).DegreesCelsius:0.#}\u00B0C");
                    Console.WriteLine($"Dew point: {WeatherHelper.CalculateDewPoint(tempValue, humValue).DegreesCelsius:0.#}\u00B0C");
                    Thread.Sleep(1000);
                }
            }
        }