Exemplo n.º 1
0
        public override void DoWork(I2C thisSensor)
        {
            I2cSensordata thisReading = new I2cSensordata();

            Sup.LogTraceInfoMessage($"I2cSensorDevice {SensorUsed}: DoWork routine entry");

            try
            {
                lock ( Response )
                {
                    thisConnect.Write(SHT31SingleShotCommand);
                    Response = thisConnect.Read(6);
                }

                // For debugging, normally not on
                Sup.LogTraceInfoMessage($"I2cSensorDevice {SensorUsed} data read: {Response[ 0 ]}; {Response[ 1 ]}; {Response[ 2 ]}; {Response[ 3 ]}; {Response[ 4 ]}; {Response[ 5 ]}; "); // {Response[6]}; {Response[7]};

                thisReading.Humidity     = 100 * (double)(Response[3] * 0x100 + Response[4]) / 65535;                                                                                       // BitConverter.ToUInt16(Response, 3) / 65535;
                thisReading.TemperatureF = -49 + 315 * (double)(Response[0] * 0x100 + Response[1]) / 65535;                                                                                 // Must be in Fahrenheit for the Davis simulation
                thisReading.TemperatureC = -45 + 175 * (double)(Response[0] * 0x100 + Response[1]) / 65535;                                                                                 // This is the same in Celsius

                thisSensor.ObservationList.Add(thisReading);
            }
            catch (Exception e)
            {
                Sup.LogTraceWarningMessage($"I2cSensorDevice Exception {SensorUsed}:...{e.Message}");
            }

            return;
        }
Exemplo n.º 2
0
        public override void DoWork(I2C thisSensor)
        {
            I2cSensordata thisReading = new I2cSensordata();

            Sup.LogTraceInfoMessage($"I2cSimulatorDevice {SensorUsed}: DoWork routine entry");
            // new DateTime(1970, 1, 1)
            thisReading.Humidity     = 70;
            thisReading.TemperatureF = 77.0;
            thisReading.TemperatureC = 25.0;

            thisSensor.ObservationList.Add(thisReading);
        }