root / Ports / PortsSHT11.h
History | View | Annotate | Download (1.1 KB)
| 1 | //>>> The latest version of this code can be found at https://github.com/jcw/ !!
|
|---|---|
| 2 | |
| 3 | // Port library interface to SHT11 sensors connected via "something like I2C"
|
| 4 | // 2009-02-16 <jcw@equi4.com> http://opensource.org/licenses/mit-license.php
|
| 5 | // $Id: PortsSHT11.h 7763 2011-12-11 01:28:16Z jcw $
|
| 6 | |
| 7 | class SHT11 : public Port {
|
| 8 | void clock(uint8_t x) const; |
| 9 | void release() const; |
| 10 | |
| 11 | uint8_t writeByte(uint8_t value) const;
|
| 12 | uint8_t waitAck() const;
|
| 13 | uint8_t readByte(uint8_t ack) const;
|
| 14 | void start() const; |
| 15 | |
| 16 | static void crcCalc(uint8_t x); |
| 17 | static void (*crcFun)(uint8_t); |
| 18 | static uint8_t crc8;
|
| 19 | public:
|
| 20 | static void enableCRC(); |
| 21 | |
| 22 | enum { TEMP, HUMI };
|
| 23 | uint16_t meas[2];
|
| 24 | |
| 25 | SHT11 (uint8_t num) : Port (num) { connReset(); }
|
| 26 | |
| 27 | void connReset() const; |
| 28 | void softReset() const; |
| 29 | |
| 30 | uint8_t readStatus() const;
|
| 31 | void writeStatus(uint8_t value) const; |
| 32 | |
| 33 | uint8_t measure(uint8_t type, void (*delayFun)() =0); |
| 34 | |
| 35 | #ifndef __AVR_ATtiny84__
|
| 36 | void calculate(float& rh_true, float& t_C) const; |
| 37 | |
| 38 | static float dewpoint(float h, float t); |
| 39 | #else
|
| 40 | //XXX TINY!
|
| 41 | #endif
|
| 42 | }; |