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