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

Method readTemperature

libraries/GY521/GY521.cpp:325–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323
324
325int16_t GY521::readTemperature()
326{
327 // DO NOT THROTTLE
328 _wire->beginTransmission(_address);
329 _wire->write(GY521_TEMP_OUT_H);
330 if (_wire->endTransmission() != 0)
331 {
332 _error = GY521_ERROR_WRITE;
333 return _error;
334 }
335
336 // Get the data
337 int8_t n = _wire->requestFrom(_address, (uint8_t)2);
338 if (n != 2)
339 {
340 _error = GY521_ERROR_READ;
341 return _error;
342 }
343 // TEMPERATURE
344 _temperature = _WireRead2(); // TEMP_OUT_H TEMP_OUT_L
345 return GY521_OK;
346}
347
348
349bool GY521::setAccelSensitivity(uint8_t as)

Callers

nothing calls this directly

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected