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

Method readTemperature

libraries/SHT2x/SHT2x.cpp:168–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166
167
168bool SHT2x::readTemperature()
169{
170 uint8_t buffer[3];
171
172 if (readBytes(3, (uint8_t*) &buffer[0], 90) == false)
173 {
174 _error = SHT2x_ERR_READBYTES;
175 return false;
176 }
177 if (crc8(buffer, 2) != buffer[2])
178 {
179 _error = SHT2x_ERR_CRC_TEMP;
180 // return false; // do not fail yet
181 }
182 _rawTemperature = buffer[0] << 8;
183 _rawTemperature += buffer[1];
184 _rawTemperature &= 0xFFFC;
185
186 // clear requestType
187 _requestType = SHT2x_REQ_NONE;
188
189 _status = buffer[1] & 0x0003;
190 if (_status == 0xFF) // TODO != 0x01 (need HW to test)
191 {
192 _error = SHT2x_ERR_READBYTES;
193 return false;
194 }
195 return true;
196}
197
198
199bool SHT2x::readHumidity()

Callers

nothing calls this directly

Calls 1

crc8Function · 0.85

Tested by

no test coverage detected