Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
sht11.h
00001 /** 00002 @file sht11.h 00003 00004 @brief Header file containing member functions and variables 00005 00006 */ 00007 00008 #ifndef __SHT11_H__ 00009 #define __SHT11_H__ 00010 00011 #include "mbed.h" 00012 00013 /** 00014 @brief Simple library for interfacing with Sensirion SHT11 00015 00016 @brief Revision 1.0 00017 00018 @author Tim Meese 00019 @date January 201 00020 * 00021 * Example: 00022 * @code 00023 00024 #include "mbed.h" 00025 #include "sht11.h" 00026 00027 // clk, dat 00028 SHT11 sht(p7, p8); 00029 00030 int main() { 00031 00032 // initialise display 00033 lcd.init(); 00034 // print a string in top-left corner 00035 lcd.printString("Hello, World!",0,0); 00036 // move cursor to 4th row 00037 lcd.setXYAddress(0,3); 00038 // print character 00039 lcd.printChar('X'); 00040 00041 while(1); 00042 } 00043 00044 * @endcode 00045 */ 00046 00047 class SHT11 00048 { 00049 00050 private: 00051 DigitalOut* clk; 00052 DigitalInOut* data; 00053 float lastTemperature; 00054 float lastHumidity; 00055 00056 void sendTransmissionStart(); 00057 void connectionReset(); 00058 void softReset(); 00059 int writeByte(unsigned char writeData); 00060 int readByte(unsigned char *pReadData, bool doAck); 00061 int readStatus(unsigned char *pRetStatus); 00062 int writeStatus(unsigned char writeValue); 00063 int measureTemp(unsigned short *pRetTempRaw); 00064 int measureHumid(unsigned short *pRetHumidRaw); 00065 float convertTempCelsius(unsigned short rawTempIn); 00066 float convertTempFahrenheit(unsigned short rawTempIn); 00067 float convertHumid(unsigned short rawHumidIn, unsigned short rawTempIn); 00068 00069 public: 00070 /** Create a SHT11 object connected to the specified pins 00071 * 00072 * @param clkPin Pin connected to clk 00073 * @param dataPin Pin connected to data 00074 * 00075 */ 00076 SHT11(PinName clkPin, PinName dataPin); 00077 00078 /** Initialise SHT11 00079 * 00080 */ 00081 void init(); 00082 int getTemperature(float * pRetTemperature); 00083 int getTempHumid(float * pRetTemperature, float * pRetHumidity); 00084 }; 00085 00086 #endif /* __SHT11_H__ */
Generated on Thu Jul 14 2022 19:02:03 by
1.7.2