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

Method read

libraries/SGP30/SGP30.cpp:180–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178
179
180bool SGP30::read()
181{
182 if (_lastRequest == 0) return false;
183 if (millis() - _lastRequest < 13) return false; // Page 11
184 _lastRequest = 0;
185
186 if (_wire->requestFrom(_address, (uint8_t)6) != 6)
187 {
188 _error = SGP30_ERROR_I2C;
189 return false;
190 }
191 _co2 = _wire->read() << 8;
192 _co2 += _wire->read();
193 uint8_t crc = _wire->read();
194 if (_CRC8(_co2) != crc)
195 {
196 _error = SGP30_ERROR_CRC;
197 return false;
198 }
199 _tvoc = _wire->read() << 8;
200 _tvoc += _wire->read();
201 crc = _wire->read();
202 if (_CRC8(_tvoc) != crc)
203 {
204 _error = SGP30_ERROR_CRC;
205 return false;
206 }
207 _error = SGP30_OK;
208 return true;
209}
210
211
212void SGP30::requestRaw()

Callers 6

getIDMethod · 0.45
getFeatureSetMethod · 0.45
measureTestMethod · 0.45
readRawMethod · 0.45
getBaselineMethod · 0.45
getTVOCBaselineMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected