private static async Task <Weather> GetWeatherAsync() { I2cConnectionSettings settings = new I2cConnectionSettings(0, Bme280.SecondaryI2cAddress); I2cDevice device = I2cDevice.Create(settings); using Bme280 bme = new Bme280(device); bme.SetPowerMode(Bmx280PowerMode.Normal); bme.SetTemperatureSampling(Sampling.UltraHighResolution); bme.SetPressureSampling(Sampling.UltraHighResolution); bme.SetHumiditySampling(Sampling.UltraHighResolution); double t = Math.Round((await bme.ReadTemperatureAsync()).Celsius, 2); double h = Math.Round(await bme.ReadHumidityAsync(), 2); double p = Math.Round(await bme.ReadPressureAsync(), 2); bme.SetPowerMode(Bmx280PowerMode.Sleep); //Console.WriteLine($"Temperature:{t} Humidity:{h} Pressure:{p}"); return(new Weather { DateTime = DateTime.Now, WeatherName = await WeatherHelper.GetXinzhiWeatherAsync(ConfigHelper.Get("Xinzhi:Key"), ConfigHelper.Get("Xinzhi:Location")), Temperature = t, Humidity = h, Pressure = p, ImageBase64 = GetImageBase64() }); }