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 has been attached.

sort by: active | newest | oldest
sinet6661 year ago

Hi,


You need to connect it using AT commands as the library is for the official shield.
I will provide you my code. I hope it helps a bit.

#include <TembooCoAPEdgeDevice.h>

#include <TembooMQTTEdgeDevice.h>

#include <SPI.h>

#include <WiFi.h>

#include <WiFiClient.h>

#include <Temboo.h>

#include "TembooAccount.h"

#include<stdlib.h>

#include <SoftwareSerial.h>

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 = 1;

// 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);

Serial.println("AT");

delay(500);

if(Serial.find("OK")){

Serial.println("OK");

connectWiFi();

}

}

void loop() {

int sensorValue = analogRead(inputPin);

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

if (sensorValue > 500) {

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);

}

boolean connectWiFi(){

Serial.println("AT+CWMODE=1");

delay(2000);

String cmd="AT+CWJAP=\"";

cmd+=WIFI_SSID;

cmd+="\",\"";

cmd+=WPA_PASSWORD;

cmd+="\"";

Serial.println(cmd);

delay(5000);

if(Serial.find("OK")){

Serial.println("OK");

return true;

}else{

return false;

}

}

void runSendEmail(int sensorValue) {

TembooChoreo SendEmailChoreo(client);

// Set Temboo account credentials

SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);

Serial.println(TEMBOO_ACCOUNT);

SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);

Serial.println(TEMBOO_APP_KEY_NAME);

SendEmailChoreo.setAppKey(TEMBOO_APP_KEY);

Serial.println(TEMBOO_APP_KEY);

// Set Choreo inputs

String FromAddressValue = "agripoffaith1@gmail.com";

Serial.println("agripoffaith1@gmail.com");

SendEmailChoreo.addInput("FromAddress", FromAddressValue);

String UsernameValue = "agripoffaith1@gmail.com";

SendEmailChoreo.addInput("Username", UsernameValue);

String ToAddressValue = "raghavendran.k@tevatrontech.org";

Serial.println("raghavendran.k@tevatrontech.org");

SendEmailChoreo.addInput("ToAddress", ToAddressValue);

String SubjectValue = "LISTEN";

SendEmailChoreo.addInput("Subject", SubjectValue);

String PasswordValue = "XYZ";

SendEmailChoreo.addInput("Password", PasswordValue);

String MessageBodyValue = "HEYYY";

SendEmailChoreo.addInput("MessageBody", MessageBodyValue);

// 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();

}

JigarF (author) 1 year ago

Sorry, I just forgot to upload the file.

The code is as below:

#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();

}

Ok and where or what exactly is your problem with the code?
If the mini code works then you most likely forgot something you had to include.
You also need to make sure the serial settings are correct for everything.
Arduino does not like it when the port on the computer is configured diffferently to the settings in the code.
If your problem is more theoretical than double check your wiring.

JigarF (author)  Downunder35m1 year ago

As I said, the temboo code is being successfully uploaded to the Arduino UNO board. The problem is why the serial monitor is displaying Shield:FAIL.

I also tried by connecting Rx-Tx and Tx-Rx of Arduino UNO-ESP8266-01 but the serial monitor still displays Shield:FAIL.

Please let me know why the serial monitor is displaying Shield:FAIL despite of correct code and connections.

1. you need to make sure you use the right connections and pins.
2. you can check the library itself for the default pin assignments.
3. I don't have your hardware at hand so I can not test the code.

Attached where please?