One approach would be to create a separate task on the ESP32 that takes care of testing this sensor, than the gateway is not affected.