/////////////////////////////////////////// READ THE SENSOR
| 88 | // READ THE SENSOR |
| 89 | // |
| 90 | int DHT20::read() |
| 91 | { |
| 92 | // do not read to fast |
| 93 | if (millis() - _lastRead < 1000) |
| 94 | { |
| 95 | return DHT20_ERROR_LASTREAD; |
| 96 | } |
| 97 | |
| 98 | int status = requestData(); |
| 99 | if (status < 0) return status; |
| 100 | // wait for measurement ready |
| 101 | while (isMeasuring()) |
| 102 | { |
| 103 | yield(); |
| 104 | } |
| 105 | // read the measurement |
| 106 | status = readData(); |
| 107 | if (status < 0) return status; |
| 108 | |
| 109 | // convert it to meaningful data |
| 110 | return convert(); |
| 111 | } |
| 112 | |
| 113 | |
| 114 | int DHT20::requestData() |
no outgoing calls