ESP is not responding message when trying to connect to Cayenne using Arduino Mega and ESP8266

Hi, I am new to Cayenne, Arduino Mega and ESP8266. I am doing an IoT based project but I can’t seem to get the ESP8266 connected. The code below was used, that was generated from the Cayenne website and the baud rate is changed to 9600. But when serial monitor is opened the ESP is not responding message is printed. However I used my mobile hotspot for the ESP8266 and I can see that the ESP is connected to the hotspot.

Hope you guys can help. I have been stuck at this for weeks.
Thanks in advanced!

//#define CAYENNE_DEBUG // Uncomment to show debug messages
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <CayenneMQTTESP8266Shield.h>

// WiFi network info.
char ssid = " ";
char wifiPassword = " ";

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = " ";
char password = " ";
char clientID = " ";

// Set ESP8266 Serial object. In this example we use the Serial1 hardware serial which is available on boards like the Arduino Mega.
#define EspSerial Serial1

ESP8266 wifi(&EspSerial);

void setup()

// Set ESP8266 baud rate

Cayenne.begin(username, password, clientID, wifi, ssid, wifiPassword);

void loop()

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
Cayenne.virtualWrite(0, millis());
// Some examples of other functions you can use to send data.
//Cayenne.celsiusWrite(1, 22.0);
//Cayenne.luxWrite(2, 700);
//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);

// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_LOG(“Channel %u, value %s”,, getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError(“Error message”);

ESP is not responding can be either your connection between esp and arduino not proper or you can try changing the esp baud rate to 115200