This repository contains a PSoC Creator Library Project featuring a Sensirion SHT7x Custom Component. As stated in the header file of the library, this work is based on the on the Sensirion SHT7x Arduino library written by Carl Jackson.
The Sensirion SHT7x sensors is a temperature and humidity sensor. According to Sensirion description, the SHTx sensor is a digital pin-type relative humidity sensor for easy replaceability in a wide range of applications. The series consists of a standard version, SHT71, which convinces with its attractive price-performance ratio, and a high-end version, SHT75.
The PSoC Custom component features all the useful methods to interface a PSoC board with an SHT7x sensor. To date, the component was tested with a PSoC 5LP Development Kit. The component requires the connection to two pins:
- Clock PIN: this pin must be connected to the clock pin of the SHT7x sensor
- Data PIN: this pin must be connected to the data pin of the SHT7x sensor with a 10k pull up resistor
A Component macro is provided, where two bidirectional pins are already connected to the component.
The API of the component allow to easily perform temperature, humidity, and dewpoint measurements. Coefficients for temperature conversion, together with formulas for temperature, humidity,nd dewpoint computation, are provided. Both high-level methods and low-level methods are accessible to the developer.
At the moment, five parameters are available:
-
Enable CRC check: to enable CRC checking when communicating with the sensor (by default it is enabled)
-
Measurement Timeout: to specify the amount of time to wait for measurement complete when using one of the blocking methods
-
OTP Reload: to determine if calibration coefficients should be uploaded to registers every time there is a measurement or not
-
Resolution: to specifiy the resolution of the sensors. The sensors provide two possible choices:
- 12 bit humidity/14 bit temperature (default)
- 8 bit humidity/12 bit temperature
-
Sensor Supply Voltage: to specify the supply voltage of the sensors. This information is used to used the correct calibration coefficients, since they vary according to the supply voltage.
Performing a temperature, humidity, and dewpoint measurement requires very few lines of code:
float temperature, humidity, dewpoint;
SHT7x_Start();
SHT7x_Measure(&temperature, &humidity, &dewpoint);
This custom component requires the use of the math
library. In the header file of the custom component this library is already included, but if you do not follow the procedure reported here, you would get the following error
Build error: undefined reference to `log'
This is due to the fact that the dewpoint computation requires the use of a logarithmic function.