MCPcopy Create free account
hub / github.com/DanielOgorchock/ST_Anything / read11

Method read11

Arduino/libraries/DHT/dht.cpp:40–61  ·  view source on GitHub ↗

return values: DHTLIB_OK DHTLIB_ERROR_CHECKSUM DHTLIB_ERROR_TIMEOUT

Source from the content-addressed store, hash-verified

38// DHTLIB_ERROR_CHECKSUM
39// DHTLIB_ERROR_TIMEOUT
40int dht::read11(uint8_t pin)
41{
42 // READ VALUES
43 int rv = _readSensor(pin, DHTLIB_DHT11_WAKEUP);
44 if (rv != DHTLIB_OK)
45 {
46 humidity = DHTLIB_INVALID_VALUE; // invalid value, or is NaN prefered?
47 temperature = DHTLIB_INVALID_VALUE; // invalid value
48 return rv;
49 }
50
51 // CONVERT AND STORE
52 humidity = bits[0]; // bits[1] == 0;
53 temperature = bits[2]; // bits[3] == 0;
54
55 // TEST CHECKSUM
56 // bits[1] && bits[3] both 0
57 uint8_t sum = bits[0] + bits[2];
58 if (bits[4] != sum) return DHTLIB_ERROR_CHECKSUM;
59
60 return DHTLIB_OK;
61}
62
63
64// return values:

Callers 1

getDataMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected