Temperatur sensor function fails with timer, works fine in loop

I've tried your code and reproduced the errors. From experimenting, loop() code seems to interrupt timers (interleaves) even though multiple timer tasks queue behind each other. Making this change to the code (even with SYSTEM_THREAD(ENABLED)), based on the suggestion from the link below, and I got 100% success:

volatile float tempCheck;
SINGLE_THREADED_BLOCK() {
    temp.requestTemperaturesByIndex(0);
    tempCheck = temp.getTempCByIndex(0);
};

Ref posting by @MrZane:

4 Likes