I'm stupid ! @Boots33 the debug info saved me. With debug info I came to notice that the sketch goes into loop part only if the gateway is also connected and available. Stupid me was doing the pin checks just by connecting the sensor and keeping the gateway disconnected , when I had the gateway connected I didn't bother to check the pin out, I was going in the same loop and wasting my and all your valuable time.
Thanks for all your assistance people, you guys are awesome.