If you put a // in front of sensors.requestTemperatures(); for instance, it will be disabled.
What you are trying to do is see if the program will run with these disabled, thus isolating the issue to stuff happening in the loop() function and not setup().
The ESP works fine with Cayenne. However, it is not officially supported, so any example sketch you find for another Arduino device may not work. The ESP is a workhorse, but it is not actually an Arduino, so some tweaks are needed.
Also double check you are using the right pin. NodeMCU maps things differently.
See that if you are using GPIO2, your device needs to be connected to D4. Personally, I would set tmpPin = 4 and stay connected to D2 as GPIO2 has other functions on the ESP that might be getting you into trouble.