MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / readData

Method readData

libraries/DHT20/DHT20.cpp:131–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129
130
131int DHT20::readData()
132{
133 // GET DATA
134 const uint8_t length = 7;
135 int bytes = _wire->requestFrom(DHT20_ADDRESS, length);
136
137 if (bytes == 0) return DHT20_ERROR_CONNECT;
138 if (bytes < length) return DHT20_MISSING_BYTES;
139
140 bool allZero = true;
141 for (int i = 0; i < bytes; i++)
142 {
143 _bits[i] = _wire->read();
144 // if (_bits[i] < 0x10) Serial.print(0);
145 // Serial.print(_bits[i], HEX);
146 // Serial.print(" ");
147 allZero = allZero && (_bits[i] == 0);
148 }
149 // Serial.println();
150 if (allZero) return DHT20_ERROR_BYTES_ALL_ZERO;
151
152 _lastRead = millis();
153 return bytes;
154}
155
156
157int DHT20::convert()

Callers

nothing calls this directly

Calls 1

readMethod · 0.45

Tested by

no test coverage detected