Ejemplo n.º 1
0
        protected override void Configure()
        {
            CheckInitialization();

            const byte controlRegisterAddress   = 0x20;
            var        controlRegisterByteValue = TemperatureAndPressureSensorHelper.ConfigureControlByte();

            RegisterHelper.WriteByte(device, controlRegisterAddress, controlRegisterByteValue);
        }
Ejemplo n.º 2
0
      protected override void Configure()
      {
          CheckInitialization();

          const byte controlRegisterAddress   = 0x20;
          var        controlRegisterByteValue = HumiditySensorHelper.ConfigureControlByte();

          RegisterHelper.WriteByte(device, controlRegisterAddress, controlRegisterByteValue);

          GetHumidityScalers();
      }
Ejemplo n.º 3
0
      public float GetHumidity()
      {
          CheckInitialization();

          const byte humidityLowByteRegisterAddress  = 0x28;
          const byte humidityHighByteRegisterAddress = 0x29;

          var rawHumidity = RegisterHelper.GetShort(device,
                                                    new byte[] { humidityLowByteRegisterAddress, humidityHighByteRegisterAddress });

          return(ConvertToRelativeHumidity(rawHumidity));
      }
Ejemplo n.º 4
0
        public float GetTemperature()
        {
            CheckInitialization();

            // Register address list
            const byte tempLowByteRegisterAddress  = 0x2B;
            const byte tempHighByteRegisterAddress = 0x2C;

            // Read low, and high bytes and convert them to 16-bit signed integer
            var temperature = RegisterHelper.GetShort(device,
                                                      new byte[] { tempLowByteRegisterAddress, tempHighByteRegisterAddress });

            // Convert to physical units [degrees Celsius]
            return(temperature / tempScaler + tempOffset);
        }
Ejemplo n.º 5
0
        public float GetPressure()
        {
            CheckInitialization();

            // Register address list
            const byte pressureLowByteRegisterAddress    = 0x28;
            const byte pressureMiddleByteRegisterAddress = 0x29;
            const byte pressureHighByteRegisterAddress   = 0x2A;

            // Read registers and convert resulting values to a 32-bit signed integer
            var pressure = RegisterHelper.GetInt(device, new byte[] {
                pressureLowByteRegisterAddress,
                pressureMiddleByteRegisterAddress,
                pressureHighByteRegisterAddress
            });

            // Convert to physical units [hectopascals, hPa]
            return(pressure / pressureScaler);
        }
Ejemplo n.º 6
0
      private void GetHumidityScalers()
      {
          CheckInitialization();

          const byte h0RegisterAddress = 0x30;
          const byte h1RegisterAddress = 0x31;

          const byte t0LowByteRegisterAddress  = 0x36;
          const byte t0HighByteRegisterAddress = 0x37;

          const byte t1LowByteRegisterAddress  = 0x3A;
          const byte t1HighByteRegisterAddress = 0x3B;

          const float hScaler = 2.0f;

          humidityScalerH0 = RegisterHelper.ReadByte(device, h0RegisterAddress) / hScaler;
          humidityScalerH1 = RegisterHelper.ReadByte(device, h1RegisterAddress) / hScaler;

          humidityScalerT0 = RegisterHelper.GetShort(device,
                                                     new byte[] { t0LowByteRegisterAddress, t0HighByteRegisterAddress });
          humidityScalerT1 = RegisterHelper.GetShort(device,
                                                     new byte[] { t1LowByteRegisterAddress, t1HighByteRegisterAddress });
      }
Ejemplo n.º 7
0
        protected bool WhoAmI(byte registerAddress, byte expectedValue)
        {
            byte whoami = RegisterHelper.ReadByte(device, registerAddress);

            return(whoami == expectedValue);
        }