SHT V4 5V UART
Fork of SHT_v1 by
Embed:
(wiki syntax)
Show/hide line numbers
SHT.h
00001 /* mbed module to use a Sensirion SHT1x /SHT7x sensor 00002 * Copyright (c) 2007-2009 Stephen McGarry 00003 * Released under the MIT License: http://mbed.org/license/mit 00004 */ 00005 #ifndef SHT_H 00006 #define SHT_H 00007 00008 #include "mbed.h" 00009 00010 00011 enum SHT_acc { 00012 SHT_low=0, 00013 SHT_high=1 00014 }; 00015 00016 typedef unsigned char byte; 00017 00018 class SHT { 00019 public: 00020 /* Constructor: SHT 00021 * Creates an SHT interface connected to specific pins. 00022 * 00023 */ 00024 SHT(PinName p_sclk, PinName p_data, SHT_acc p_accuracy); 00025 00026 /* Functions 00027 */ 00028 float get_temperature(); // get the most recent temp reading 00029 float get_humidity(); // get the most recent humidity reading 00030 float get_dewpoint(); // get the most recent dewpoint value 00031 int update(SHT_acc accuracy); // update stored values from sensor 00032 00033 protected: 00034 byte read_byte(bool send_ack); 00035 char write_byte(byte value); 00036 void trans_start(void); 00037 void connection_reset(void); 00038 char soft_reset(); 00039 char read_status(byte &value); 00040 char write_status(byte value); 00041 char measure(int &value, byte mode); 00042 void calculate(); 00043 00044 DigitalOut sclk; 00045 DigitalInOut data; 00046 SHT_acc accuracy; // will we use high or low accuracy mode on the sensor 00047 00048 float temperature; // calculated from sensor reading 00049 float humidity; 00050 float dewpoint; 00051 int temp,hum; // integer values from sensor before conversion 00052 00053 enum commands { 00054 com_read_status_reg=0x06, 00055 com_write_status_reg=0x07, 00056 com_measure_temp=0x03, 00057 com_measure_humid=0x05, 00058 com_reset=0x1E 00059 }; 00060 00061 enum acks { 00062 no_ack=0, 00063 send_ack=1 00064 }; 00065 }; 00066 00067 #endif
Generated on Thu Jul 21 2022 09:15:20 by
1.7.2
frederic blanc
