Exemplo n.º 1
0
        // Timer Ro
        private void Timer_Tick(object sender, object e)
        {
            // Read Raw Temperature and Humidity
            int RawTemperature = sht15.ReadRawTemperature();

            TemperatureC = sht15.CalculateTemperatureC(RawTemperature);
            TemperatureF = sht15.CalculateTemperatureF(RawTemperature);
            Humidity     = sht15.ReadHumidity(TemperatureC);

            StringBuilder _temperature = new StringBuilder();

            _temperature.AppendLine(MainPage.TemperatureC.ToString(".00") + "℃");

            StringBuilder _humidity = new StringBuilder();

            _humidity.AppendLine(MainPage.Humidity.ToString(".00") + "%");

            StringBuilder _time = new StringBuilder();

            _time.AppendLine(DateTime.Now.ToString("yyyy.MM.dd" + "  " + "HH:mm:ss"));

            Time.Text     = _time.ToString();
            Temp.Text     = _temperature.ToString();
            Hum.Text      = _humidity.ToString();
            SensorID.Text = sensorID.ToString();


            uploadHelper++;
            if (uploadHelper >= uploadspac)
            {
                ConnectTheDotsSensor sensor = ctdHelper.sensors[0];
                sensor.guid         = Guid.NewGuid().ToString();
                sensor.location     = sensorLocation;
                sensor.deviceid     = sensorID; //sensor id for wq
                sensor.temperatureC = TemperatureC.ToString();
                sensor.temperatureF = TemperatureF.ToString();
                sensor.humidity     = Humidity.ToString();
                //upload Data To EventHub
                ctdHelper.SendSensorData(sensor);
                uploadHelper = 0;
            }
        }
Exemplo n.º 2
0
 public void SendSensorData(ConnectTheDotsSensor sensor)
 {
     //sensor.timecreated = DateTime.UtcNow.ToString("o");
     sendMessage(sensor.ToJson());
 }