Code that connecting the nodemcu with arduino mega

you can directly connect your Nodemcu to cayenne Adding a New Device using MQTT