Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error checking in readRegister #9

Open
fl4p opened this issue Oct 5, 2023 · 1 comment
Open

Error checking in readRegister #9

fl4p opened this issue Oct 5, 2023 · 1 comment

Comments

@fl4p
Copy link

fl4p commented Oct 5, 2023

Hi,

readRegister misses error checking of the i2c calls. If for example requestFrom fails, i.e. returns 0, or no data is available, the function returns 0. This causesgetBusVoltage_V to return zero when there is a problem with the i2c bus, so we don't know if the read failed or actually reading zero voltage.

@wollewald
Copy link
Owner

@fl4p, I added the function getI2cErrorCode() which return the return value of endTransmission. I updated the example sketches Trigger.ino and Continuous.ino to show how it works.

I have also added a timeout check for startSingleMeasurement() of 2 seconds to avoid that the program hangs forever in case of unavailability of the INA226.

The changes are implemented in the new release 1.2.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants