optimized getfromsensor with caching