Ejemplo n.º 1
0
        /// <summary>
        /// Tests the temperature sensor.
        /// </summary>
        public static void TestTempSensor()
        {
            var sensor = new TemperatureSensorAM2302(Pi.Gpio[P1.Gpio17]);

            sensor.OnDataAvailable += (s, e) => $"Temperature: {e.TemperatureCelsius} | Humidity: {e.HumidityPercentage}".Info("AM2302");

            sensor.Start();
            Console.ReadKey(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tests the temperature sensor.
        /// </summary>
        public static void TestTempSensor()
        {
            var sensor = new TemperatureSensorAM2302(Pi.Gpio[BcmPin.Gpio18]);

            sensor.OnDataAvailable += (s, e) => $"Temperature: {e?.TemperatureCelsius ?? 0} | Humidity: {e?.HumidityPercentage ?? 0}".Info("AM2302");

            sensor.Start();
            Console.ReadKey(true);
            sensor.Dispose();
        }
Ejemplo n.º 3
0
        public void Start()
        {
            _tempSensor.Start();

            _tempSensor.OnDataAvailable += (sender, eventArgs) =>
            {
                if (eventArgs.TemperatureCelsius == Config.Temperature &&
                    eventArgs.HumidityPercentage == Config.Humidity)
                {
                    return;
                }

                Config.Temperature = eventArgs.TemperatureCelsius;
                Config.Humidity    = eventArgs.HumidityPercentage;

                Log.Information($"{Config.Temperature} °C");
                Log.Information($"{Config.Humidity}% Humidity");
            };
        }