I am using a SHT31 sensor with the SHT31 I2C library. It seems to work correctly measuring temperature and humidity values, but I sometimes get the error
If you get the datasheet and read it, you’ll find 0x2400 means “single shot high repeatability measurement”. The write error seems to indicate that the measurement could not start.
You should find the reason why that is happening, which looks like hardware problems.
Do you have proper pull-ups for your bus speed ? Are you using the correct voltage ? Cable length ? Bus capacitance ? Did you see the signals with an oscilloscope ?
If signals look good and everything seems to be correct, then grabbing the dialog with a logic analyzer can shed some light on what is going on. In this case looks like the write transaction is not taking place but it could also be interrupted; you should always see real life with proper measurement tools.
On the software side, are you perhaps polling too frequently ? Could one of your polls interrupt another one taking place at that moment ?