Ejemplo n.º 1
0
 private void TemperatureSensor_TemperatureRead(object sender, TemperatureReadingArgs e)
 {
     sensorDataSender.SendObjectAsJson(new SensorReading
     {
         name = "Temp sensor 1",
         id   = "room1_temp",
         data = new List <Measurement>()
         {
             new Measurement {
                 measurement_time = DateTime.Now,
                 value            = e.Temperature.ToString(),
                 unit             = "°C",
             },
             new Measurement {
                 measurement_time = DateTime.Now,
                 value            = e.Humidity.ToString(),
                 unit             = "%",
             }
         }
     });
 }
Ejemplo n.º 2
0
        private void ReadDistance(object state)
        {
            var distanceReading = _distanceSensor.Read();

            if (distanceReading == null)
            {
                return;
            }
            sensorDataSender.SendObjectAsJson(new SensorReading
            {
                name = "Distance sensor 1",
                id   = "room1_dist",
                data = new List <Measurement>
                {
                    new Measurement
                    {
                        measurement_time = DateTime.Now,
                        value            = distanceReading.DistanceInCm.ToString(),
                        unit             = "cm",
                    }
                }
            });
        }