wifi connection error

i tried to make a connection to wifi using arduino mega and cytron shield esp wifi rev 2.0. After i upload and run the program i get this message from serial monitor “Couldn’t get a wifi connection”. my wifi use wpa2 PSK type.

this is my code.

#include <WiFi.h>

char ssid = “wifiname”; // your network SSID (name)
char pass = “1234f56”; // your network password
int status = WL_IDLE_STATUS; // the Wifi radio’s status

void setup() {
// initialize serial:

// attempt to connect using WPA2 encryption:
Serial.println(“Attempting to connect to WPA network…”);
status = WiFi.begin(ssid, pass);

// if you’re not connected, stop here:
if ( status != WL_CONNECTED) {
Serial.println(“Couldn’t get a wifi connection”);
// if you are connected, print out info about the connection:
else {
Serial.println(“Connected to network”);

void loop() {
// do nothing

See libraries/WiFi/src/utility/wl_definitions.h for the list of possible status values. Then you can display the status and see if the value points to some specific cause.