Beginning of the year ... the uPLibrary grows and upgrade to version 1.9 !
One of the new features added is the managed driver for the temperature and humidity sensor SHT1x of Sensirion, which is available in a convenient breakout board of DFRobot.

SHT1x_Humidity_a_50b6083927d83_thumb[1]

The communication protocol is expected to be a non-standard I2C, so the .Net Micro Framework classes dedicated I2C are unusable. In this case, the only solution is the bit banging, through which the date and clock signals are driven directly by software. The implemented class SHT1x provides a constructor which pass the two pins used for the aforesaid signals over the power supply voltage supplied to the sensor. The latter information is necessary for the implementation of compensation formulas for the calculation of the actual value of temperature and humidity from the data read from the sensor. The methods exposed are trivially as follows:

  • ReadTemperature (): provides the measured temperature, on the basis of the unit of measure passed as a parameter;
  • ReadRelativeHumidity (): returns the value of the relative humidity (in percentage);

The use of the driver is almost immediate and shown below with a simple code, using the Netduino board and connecting the signals DATA and CLOCK sensor respectively to digital pins D0 and D1 of the board. Of course, you also need to connect the ground (GND) and power supply (VCC) in this case to 3.3 V.

   1: double temp, humidity;
   2: SHT1X sht1x = new SHT1X(Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1, SHT1X.Voltage.Vdd_3_5V);
   3:  
   4: while (true)
   5: {
   6:     temp = sht1x.ReadTemperature(SHT1X.TempUnit.Celsius);
   7:     humidity = sht1x.ReadRelativeHumidity();
   8:     Debug.Print("Temp = " + temp + " Humidity =  " + humidity);
   9:     Thread.Sleep(1000);
  10: }

The library is also updated on Nuget and thus easily integrated into your application through its package manager for Visual Studio.