Lib for HYT temp & humidity sensor

Dependents:   HYT_example Temp_&_RH_at_TFT-demo Temp_&_RH_at_TFT_with_touchscreen Temp_&_RH_at_TFT_with_touchscreen-ENG ... more

Fork of HYT by Ksenia Kondrashova

This is a simple library for the HYT-271, HYT-221 and HYT-939 humidity and temperature sensors by IST-AG company. The difference between HYT sensors is only a package.

/media/uploads/Ksenia/3-in-1-small.png

General information:

  • High precision: +/-1.8%RH and 0.2°C
  • Temperature range: -40°C to +125°C
  • Low drift : less than 0,5% RH / year
  • Power consumption: 22 µA during operation
  • Fully calibrated and compensated humidity and temperature signal
  • Digital I2C interface (14 bit values)

Product Page: http://www.ist-ag.com/eh/ist-ag/en/home.nsf/contentview/~humidity-modules

Remember to use pull-up resisrors:

/media/uploads/Ksenia/freshpaint-20-2016.09.16-10.37.03.png

You can also find Hello Word program sending data from sensor to PC via serial interface: https://developer.mbed.org/users/Ksenia/code/HYT_example/

Library doesn't contain command mode instructions. There are only functions for polling the HYT sensor with default i2c address

Revision:
0:cb02bfe8cf44
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HYT.h	Wed Sep 14 15:22:42 2016 +0000
@@ -0,0 +1,85 @@
+#ifndef MBED_HYT_H
+#define MBED_HYT_H
+
+#include "mbed.h"
+
+/**
+ * IST HYT Humidity and Temperature Sensor
+ *
+ * @code
+ * #include "mbed.h"
+ * #include "HYT.h"
+ * 
+ * Serial              pc(USBTX, USBRX);
+ * Ticker              timeKeeping;
+ * HYT                 SENSOR (I2C_SDA, I2C_SCL);
+ * 
+ * // HYT sensor polling cycle
+ * void dataUpdate(void)
+ * {
+ *     SENSOR.MRCommand();
+ *     wait_ms(100);
+ *     SENSOR.DFCommand();
+ * }
+ * 
+ * void secondsCallback(void) {
+ *     pc.printf("Humidity level: %.1f\r\n%", SENSOR.humidity);
+ *     pc.printf("Temperature level: %.1f\r\n%", SENSOR.temperature);
+ *     pc.printf("-------------------------------\r\n%", SENSOR.temperature);
+ * }
+ * 
+ * int main()
+ * {
+ *     timeKeeping.attach(&secondsCallback, 1.0f);
+ *     while(1) {
+ *          dataUpdate();
+ *     }
+ * }
+ * @endcode
+ */
+
+
+#define HYT_ADDR 0x50 // 01010000
+
+class HYT
+{
+    
+public:
+    /**
+     * HYT constructor.
+     *
+     * @param   sda mbed pin to use for SDA line of I2C interface.
+     * @param   scl mbed pin to use for SCL line of I2C interface.
+     * 
+     * Remember about pull-up resistors on sda and scl. Recommended value is 2.4 kΩ
+     */
+    HYT(PinName sda, PinName scl);
+
+    /**
+     * @brief   The totals (temperature in Celsius, relative humidity in percentages)
+     */
+    float humidity;
+    float temperature;
+    
+    /**
+     * @brief   Send "Measuring Request" command
+     * @details Initiates a measuring cycle of HYT sensor
+     * @details More information: http://www.ist-ag.com/eh/ist-ag/resource.nsf/imgref/Download_AHHYTM_E2.2.5.pdf/$FILE/AHHYTM_E2.2.5.pdf
+     */     
+    void MRCommand(void);
+    
+    /**
+     * @brief   Send "Data Fetch" command & processing the data
+     * @details Fetch the last measured value of humidity and temperature from sensor
+     * @details Calculate values of temperature in Celsius, relative humidity in percentages
+     * @details More information: http://www.ist-ag.com/eh/ist-ag/resource.nsf/imgref/Download_AHHYTM_E2.2.5.pdf/$FILE/AHHYTM_E2.2.5.pdf
+     * @returns 0 if no errors, -1 if no new value received from sensor.
+     */    
+     int DFCommand(void);
+     
+private:
+
+    I2C _i2c;
+};
+
+#endif
\ No newline at end of file