brian-lc / OpenWater

All source files, 3d parts, PCB gerbers, and documentation for open source water quality monitoring

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No need to wait after Wire.requestFrom().

Koepel opened this issue · comments

In the file "open_water_v2.cpp" in the function "wireTakeMeasure()" it starts with a Wire.requestFrom(). It seems odd to start with some kind of dummy read and not using the data that was read.

After the Wire.requestFrom(), that is the real one, the second one, there is a timeout with millis() and delay(1). You can remove that timeout, there is nothing to wait for.

When the Wire.requestFrom() returns, the I2C transaction has completely finished and the data is waiting in a buffer in the Wire library.

The makeMeasurement() function here: https://github.com/sparkfun/Si7021_Breakout/tree/master/Libraries/Arduino/Si7021/src does not have that dummy read, nor the timeout.