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.
Fork of driver_mbed_TH02 by
driver_mbed_TH02.h
00001 /* 00002 * TH02_dev.h 00003 * Driver for DIGITAL I2C HUMIDITY AND TEMPERATURE SENSOR 00004 * 00005 * Copyright (c) 2014 seeed technology inc. 00006 * Website : www.seeed.cc 00007 * Author : Oliver Wang 00008 * Create Time: April 2014 00009 * Change Log : 00010 * 00011 * The MIT License (MIT) 00012 * 00013 * Permission is hereby granted, free of charge, to any person obtaining a copy 00014 * of this software and associated documentation files (the "Software"), to deal 00015 * in the Software without restriction, including without limitation the rights 00016 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00017 * copies of the Software, and to permit persons to whom the Software is 00018 * furnished to do so, subject to the following conditions: 00019 * 00020 * The above copyright notice and this permission notice shall be included in 00021 * all copies or substantial portions of the Software. 00022 * 00023 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00024 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00025 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00026 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00027 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00028 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00029 * THE SOFTWARE. 00030 */ 00031 00032 #ifndef _TH02_DEV_H 00033 #define _TH02_DEV_H 00034 00035 /****************************************************************************/ 00036 /*** Including Files ***/ 00037 /****************************************************************************/ 00038 // #include <Wire.h> 00039 // #include <Arduino.h> 00040 # include "mbed.h" 00041 00042 /****************************************************************************/ 00043 /*** Macro Definitions ***/ 00044 /****************************************************************************/ 00045 // #define TH02_I2C_DEV_ID 0x40 00046 const int TH02_I2C_DEV_ID = 0x40<<1; 00047 //Address for mbed 00048 00049 #define REG_STATUS 0x00 00050 #define REG_DATA_H 0x01 00051 #define REG_DATA_L 0x02 00052 #define REG_CONFIG 0x03 00053 #define REG_ID 0x11 00054 00055 #define STATUS_RDY_MASK 0x01 //poll RDY,0 indicate the conversion is done 00056 00057 #define CMD_MEASURE_HUMI 0x01 //perform a humility measurement 00058 #define CMD_MEASURE_TEMP 0x11 //perform a temperature measurement 00059 00060 #define TH02_WR_REG_MODE 0xC0 00061 #define TH02_RD_REG_MODE 0x80 00062 /****************************************************************************/ 00063 /*** Class Definition ***/ 00064 /****************************************************************************/ 00065 class TH02_dev 00066 { 00067 public: 00068 void begin(); 00069 uint8_t isAvailable(); 00070 float ReadTemperature(void); 00071 float ReadHumidity(void); 00072 private: 00073 void TH02_IIC_WriteCmd(uint8_t u8Cmd); 00074 uint8_t TH02_IIC_ReadReg(uint8_t u8Reg); 00075 void TH02_IIC_WriteReg(uint8_t u8Reg,uint8_t u8Data); 00076 uint16_t TH02_IIC_ReadData(void); 00077 uint16_t TH02_IIC_ReadData2byte(void); 00078 }; 00079 00080 extern TH02_dev myTH02; 00081 00082 #endif // _TH02_DEV_H
Generated on Mon Aug 8 2022 00:48:49 by
1.7.2
