Shield:FAIL problem in ESP8266-01 with Arduino UNO

I have been working on a Security System project wherein I should get an email if the PIR sensor detects any human presence.

I have used an Arduino UNO, ESP8266-01 WiFi module and a PIR sensor.

Power supply:

Arduino is powered through the USB connection of desktop and ESP8266-01 is powered through the 3.3V pin of Arduino UNO and I have not faced any problem with that 3.3V connection of Arduino.

The connection between Arduino UNO and ESP8266-01 are as follows:

Arduino UNO ESP8266-01

Rx Rx

Tx Tx

3.3V CH_PD & VCC

GND GND

GPIO0 and GPIO2 left open.

After successfully uploading the ‘BareMinimum’ code as found in ‘File>Examples>Basics’ of Arduino IDE, the ESP8266 is able to communicate correctly i.e. connecting to a wifi network or serving as an access point via SERIAL MONITOR.The ESP8266-01 displays ‘0018000902-AI03’ as the firware version when I type AT+GMR in the serial monitor of Arduino IDE v1.6.8

Then I created an account on https://temboo.com/ and used the ‘SendEmail’ choreo as found under ‘Google>Gmail>SendEmail’.

I selected the ‘Arduino’ option in one tab and ‘Arduino Wifi’ option in another tab.I then entered the required details including the ‘App specific password’ and I was able to successfully run the choreo.

Problem:

I was able to successfully upload the code to my Arduino UNO that was generated by Temboo.

But after uploading the code, when I’m opening my SERIAL MONITOR window from Arduino IDE a message “Shield:FAIL” is being displayed.

I’m not able to communicate with the ESP8266 any further.

But if I upload the BareMinimum code again, then ESP8266 works normally.

I’m a newbie and dont know much about the programming of Arduino though some basics of C are clear.Please if anyone can help me with this, I would be very grateful.

The code is as follows:

#include <SPI.h>

#include <WiFi.h>

#include <WiFiClient.h>

#include <Temboo.h>

#include “TembooAccount.h” // Contains Temboo account information

WiFiClient client;

// The number of times to trigger the action if the condition is met

// We limit this so you won’t use all of your Temboo calls while testing

int maxCalls = 10;

// The number of times this Choreo has been run so far in this sketch

int calls = 0;

int inputPin = A0;

void setup() {

Serial.begin(9600);

// For debugging, wait until the serial console is connected

delay(4000);

while(!Serial);

int wifiStatus = WL_IDLE_STATUS;

// Determine if the WiFi Shield is present

Serial.print(“\n\nShield:”);

if (WiFi.status() == WL_NO_SHIELD) {

Serial.println(“FAIL”);

// If there’s no WiFi shield, stop here

while(true);

}

Serial.println(“OK”);

// Try to connect to the local WiFi network

while(wifiStatus != WL_CONNECTED) {

Serial.print(“WiFi:”);

wifiStatus = WiFi.begin(WIFI_SSID, WPA_PASSWORD);

if (wifiStatus == WL_CONNECTED) {

Serial.println(“OK”);

} else {

Serial.println(“FAIL”);

}

delay(5000);

}

// Initialize pins

pinMode(inputPin, INPUT);

Serial.println(“Setup complete.\n”);

}

void loop() {

int sensorValue = analogRead(inputPin);

Serial.println("Sensor: " + String(sensorValue));

if (sensorValue >= 2) {

if (calls < maxCalls) {

Serial.println(“\nTriggered! Calling SendEmail Choreo…”);

runSendEmail(sensorValue);

calls++;

} else {

Serial.println(“\nTriggered! Skipping to save Temboo calls. Adjust maxCalls as required.”);

}

}

delay(250);

}

void runSendEmail(int sensorValue) {

TembooChoreo SendEmailChoreo(client);

// Set Temboo account credentials

SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);

SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);

SendEmailChoreo.setAppKey(TEMBOO_APP_KEY);

// Set profile to use for execution

SendEmailChoreo.setProfile(“JigarFaria”);

// Identify the Choreo to run

SendEmailChoreo.setChoreo(“/Library/Google/Gmail/SendEmail”);

// Run the Choreo

unsigned int returnCode = SendEmailChoreo.run();

// Read and print the error message

while (SendEmailChoreo.available()) {

char c = SendEmailChoreo.read();

Serial.print(c);

}

Serial.println();

SendEmailChoreo.close();

}