Sensirion SHT11 Class
Joyed by the fact that it’s inexpensive and has an serial interface I’ve ordered an Sensirion SHT11 Temperature and Humidity sensor module from Parallax. After recieving it I’ve discovered that the serial interface isn’t an standard serial interface like SPI or I2C. To communicate with the SHT11 I’ve created an .NET Micro Framework 3.0 class. It handles the communication with the SHT11 and processes the raw values to usable ones.
The class solution has two parts:
- IO provider for SHT11
- The SensirionSHT11 class
You can download the Class Solution with a Demo application here: MF_Sensirion_SHT11.zip
IO Provider:
To allow you to easely modify the way the SHT11 is connected to you’re board i’ve created an IO provider interface. In the demo solution an GPIO IO provider is included that is usable for most senarios. With you’re own IO provider you could connect an SHT11 trough an PCF8574 IO expander for example.
IO Provider Interface:
/// Interface for SHT11
/// See <see cref="SHT11_GPIO_IOProvider" /> for an implementation
/// </summary>
public interface ISHT11_IOProvider
{
bool Data
{
get;
set;
}
bool Clock
{
get;
set;
}
}
SensirionSHT11 Class:
The SensirionSHT11 class handles communication with the SHT11 trough an IO provider. It calculates the Temperature in Celcius or Farenheid with the VDD compensation described in the datasheet. Also Relative Humidity with temperature compensation is available.
Constructor:
/// Initialize SHT11 Class
/// </summary>
/// <param name="IOProvider">IOProvider to use for communication with the SHT11</param>
public SensirionSHT11(ISHT11_IOProvider IOProvider)
Enum types:
/// Select VDD voltage where SHT11 is powered from
/// </summary>
public enum SHT11VDD_Voltages
/// <summary>
/// Select temperature unit
/// </summary>
public enum SHT11TemperatureUnits
/// <summary>
/// Settings that can be written to the Status register
/// </summary>
[Flags]
public enum SHT11Settings
Functions:
/// <summary>
/// Soft Reset the SHT11, Reset interface, Clear status register
/// </summary>
/// <returns>True on error, False on succes</returns>
public bool SoftReset()
/// <summary>
/// Read temperature compensated relative humidity
/// </summary>
/// <param name="VDD">VDD for SHT11</param>
/// <returns>Relative Humidity in percent</returns>
public double ReadRelativeHumidity(SHT11VDD_Voltages VDD)
/// <summary>
/// Read RAW Unprocessed Humidity
/// </summary>
/// <returns>SHT11 Humidity</returns>
public int ReadHumidityRaw()
/// <summary>
/// Read Temperature
/// </summary>
/// <param name="VDD">VDD Voltage for SHT11</param>
/// <param name="TemperatureUnit">Temperature units to return</param>
/// <returns>Temperature in TemperatureUnit units</returns>
public double ReadTemperature(SHT11VDD_Voltages VDD, SHT11TemperatureUnits TemperatureUnit)
/// <summary>
/// Read RAW temperature value
/// </summary>
/// <returns>SHT11 Temperature</returns>
public int ReadTemperatureRaw()
/// <summary>
/// Write Status Register
/// </summary>
/// <param name="Settings">Settings to write</param>
/// <returns>True on error, False on succes</returns>
public bool WriteStatusRegister(SHT11Settings Settings)
/// <summary>
/// Read Status Register
/// </summary>
/// <returns></returns>
public SHT11Settings ReadStatusRegister()
it is possible to run them on a ghi dev board?
do you have the hardware schematics to connect them towards the board?
Thx
Yes, I used two GPIO pins on the GHI Dev board. I’m not at home but adding a schematic can be usefull for more people.. I’ll add it when I get home!
i fixed the problem. i use this schematics http://pol3cat.de/privat/SHT1-SPI.JPG
now it works on TXD1 E29 and RXD2 E28
Yes, It’s very easy.. Thanks for sharing!
Its interesting,
my final project also use SHT11 and PC Embedded (EBOX 4300) that have serial port. I want to know how to enable programimng from EBOX 4300 to SHT11,
is the component PCF8574 only i need to make connection to my EBOX?
do you have any suggestion
thanks…