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


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.


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.

After connecting Rx-Tx and Tx-Rx of Arduino UNO-ESP8266-01, the serial monitor still displays 'Shield:FAIL'.

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 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() {

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

  int wifiStatus = WL_IDLE_STATUS;

  // Determine if the WiFi Shield is present
  if (WiFi.status() == WL_NO_SHIELD) {

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


  // Try to connect to the local WiFi network
  while(wifiStatus != WL_CONNECTED) {
    wifiStatus = WiFi.begin(WIFI_SSID, WPA_PASSWORD);

    if (wifiStatus == WL_CONNECTED) {
    } else {

  // 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...");
    } else {
      Serial.println("\nTriggered! Skipping to save Temboo calls. Adjust      maxCalls as required.");

void runSendEmail(int sensorValue) {
  TembooChoreo SendEmailChoreo(client);

  // Set Temboo account credentials

  // Set profile to use for execution
  // Identify the Choreo to run

  // Run the Choreo
  unsigned int returnCode = SendEmailChoreo.run();

  // Read and print the error message
  while (SendEmailChoreo.available()) {
    char c = SendEmailChoreo.read();
  • 1
    Before taking a look at the code, I see 2 major issues in your circuit. First, Arduino 3.3V supply pin won't be enough for the current required by ESP8266 for operations. Second, you should not directly connect Arduino RX/TX pins to ESP8266 RX/TX pins, you need a level adapter, otherwise you may just kill your ESP8266.
    – jfpoilpret
    Apr 2, 2016 at 7:13
  • 1
    That code is for the Arduino WiFi shield, not the ESP8266.
    – Majenko
    Apr 2, 2016 at 9:39
  • @jfpoilpret What is a level adapter? Apr 3, 2016 at 15:54
  • @Majenko Is there any way I can make the code work for esp8266 as I don't know much about programming? Apr 3, 2016 at 15:55
  • Get the right library for your WiFi board. Examine the examples. Integrate your existing code with a suitable example.
    – Majenko
    Apr 3, 2016 at 15:56

2 Answers 2

  1. You seem to have the ESP connected via serial, but aren't sending it anything.
  2. The Rx of the ESP needs to be connected to the Tx of the Arduino (via a logic level shifter) and the Tx of the ESP needs to be connected to the Rx of the Arduino.
  3. Do you know with a proper email sending library you could use any email server, not some service that you may have to pay for?
  4. The ESP8366 is a much more capable device than the Arduino (IMO). I suspect that you could directly connect your sensor to it, and program it (in Arduino C/C++) through the Arduino IDE and it would be much less hassle.
  5. I think the problem with your code is that you haven't initialised the Wifi object, the first time you call it is to ask the status. However I don't think you need this code because its not talking to the ESP8266 and you should be sending the data via the serial connection.

Both @CodeGorilla and @Majenko make valid points.

The shield esp will talk with the uno through Serial and your esp8266 has the AT firmware on it. The BareMinimum reads input from serial and prints what the esp is sending . the code you posted has code meant for the Uno and code meant for the shield esp.

That wont work.

Your should use the arduino library for esp8266 (https://github.com/esp8266/Arduino,) make a suitable code for it , connect your sensor to the shield and forget the uno.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.