Sensiron SHT 7x Temperature and humidity device library
Dependents: temp xj-Nucleo-F303K8-SHT75-TEST
sht7X.h
- Committer:
- nimbusgb
- Date:
- 2010-10-27
- Revision:
- 1:20aa2d4a28bf
- Child:
- 2:dd218144f9fe
File content as of revision 1:20aa2d4a28bf:
/* mbed Sensiron SHT7x temperature and humidity sensor library
*
* Sensiron data at http://www.sensirion.com/en/01_humidity_sensors/06_humidity_sensor_sht75.htm
*
* Copyright (c) Ian Molesworth October 2010
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to use
* copy or modify the software for private or non-commercial purposes only.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef SHT75_H
#define SHT75_H
#include "mbed.h"
const float C1= -4.0; // for 12 Bit humi
const float C2= +0.0405; // for 12 Bit humi
const float C3= -0.0000028; // for 12 Bit hum
const float TL= -39.61; // 3v 14 bit
const float T1= +0.01; // for 14 Bit @ 5V
const float T2= +0.00008; // for 14 Bit @ 5V
/** SHT7x class
*
* Example:
* @code
* //initialise the device read temperature ticks, read humidity ticks and then
* calculate the liniarised humidity value.
* #include "mbed.h"
* #include "SHT7X.h"
00035 *
00036 * Servo myservo(p21);
00037 *
00038 * int main() {
00039 * while(1) {
00040 * for(int i=0; i<100; i++) {
00041 * myservo = i/100.0;
00042 * wait(0.01);
00043 * }
00044 * for(int i=100; i>0; i--) {
00045 * myservo = i/100.0;
00046 * wait(0.01);
00047 * }
00048 * }
00049 * }
00050 * @endcode
00051 */
class SHT75
{
public:
/** Create an SHT object connected to the specified Digital pins
*
* @param pclock digital pin to use as clock
* @param pdata digital pin to use as data bus ( bidirectional )
*/
SHT75(PinName pclock, PinName pdata): _clock(pclock), _data(pdata) {};
/** read the temperature ticks value 14 bit resolution
*
* @param int *temp pointer to an integer to hold the tick value
* @returns boolean true if read acknowledges
*/
bool readTempTicks(int* temp);
/** read the humidity ticks value 12 bit resolution
*
* @param int *temp pointer to an integer to hold the tick value
* @returns boolean true if read acknowledges
*/
bool readHumidityTicks(int* temp);
/** start up reset
*
* call to resync or abort current operation.
* worth calling every now and then to make sure your system is not hung.
*/
void reset(void);
void softReset(void);
int readStatus(void);
private:
DigitalInOut _data;
DigitalOut _clock;
void start(void);
int read(char);
bool write(char);
};
#endif