Skip to content

Latest commit

 

History

History
56 lines (38 loc) · 1.39 KB

README.md

File metadata and controls

56 lines (38 loc) · 1.39 KB

Si7021 - Temperature & Humidity Sensor

The Si7021 device provides temperature and humidity sensor readings with an I2C interface.

Documentation

Board

Sensor image Si7021 sensor

Usage

Hardware Required

  • Si7021
  • Male/Female Jumper Wires

Circuit

  • SCL - SCL
  • SDA - SDA
  • VCC - 5V
  • GND - GND

Code

I2cConnectionSettings settings = new I2cConnectionSettings(1, Si7021.DefaultI2cAddress);
I2cDevice device = I2cDevice.Create(settings);

using (Si7021 sensor = new Si7021(device, Resolution.Resolution1))
{
    while (true)
    {
        var tempValue = sensor.Temperature;
        var humValue = sensor.Humidity;

        Console.WriteLine($"Temperature: {tempValue.Celsius:0.#}\u00B0C");
        Console.WriteLine($"Relative humidity: {humValue:0.#}%");

        // WeatherHelper supports more calculations, such as saturated vapor pressure, actual vapor pressure and absolute humidity.
        Console.WriteLine($"Heat index: {WeatherHelper.CalculateHeatIndex(tempValue, humValue).Celsius:0.#}\u00B0C");
        Console.WriteLine($"Dew point: {WeatherHelper.CalculateDewPoint(tempValue, humValue).Celsius:0.#}\u00B0C");
        Console.WriteLine();

        Thread.Sleep(1000);
    }
}

Result

Sample result