Sensor code much more stable.
Also clearing the pulse if not data arrived after 5 seconds