"Failed to write to i2c port for write" with cpp demos
571 Views - Created 30/10/2022
The Expander Pi library tries to write to the RTC when it initialises the object. As the RTC was locked by the hwclock module this was blocking access to the I2C address and causing the code to fail.
I have updated the Expander Pi library with a new "usertc" parameter in the ExpanderPi function so setting the parameter to false it bypasses the RTC initialisation and allows the code to work correctly. You can download the updated library from our GitHub repository at https://github.com/abelectronicsuk/ABElectronics_CPP_Libraries/tree/master/ExpanderPi
When you create an ExpanderPi object you will need to pass in values for the initialise and usertc parameters. For example,
ExpanderPi expi(true, false);
Hopefully, this will fix the problem you are having and allow you to use the ADC when the hwclock is operational.
Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.