pulseIn retuns zero every second time called

J-M-L:
and GND are connected I suppose when you wire all this on your m0?

yes, im using a common ground for everything.