Yun sketch runs great plugged into USB, fails when plugged into wall

Hi - I must be missing something basic but I have a sketch using Temboo to send SMS. With Yun plugged into my laptop via usb, the sketch works great. It sends me a sms every minute.

I need this however to run plugged into wall. I cant simply leave my laptop connected to Yun.

When I plug the Yun into the wall, its powers up. All seems normal, but it seems as though the sketch never runs.

The same is true when I plug the Yun back into my laptop. I must upload the sketch again in order to get it to run.

Given that the sketch is uploaded, is there a way to 'start,' or run the sketch while the Yun is plugged in to a wall socket?

Going to guess its the wait…I have this…its coming to me now…yes its the BLINK sketch…Nope Oh well

And your sketch is what exactly ?
Post it here and you should know to use CODE TAGS ( </> )

Also asking this thread be moved to … wait I have another guess in my mind…Dang its gone but lets see if they will put it in the YUN section for us. (yup there is a section for them)

Thanks Ballscrewbob. Code for sketch is below. This works well with the arduino yun connected via usb to my laptop, but it seems not to run when I connect the Yun to an outlet.


  Demonstrates sending an SMS via Twilio using Temboo from an Arduino Yún.


#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information
                           // as described in the footer comment below


// Note that for additional security and reusability, you could
// use #define statements to specify these values in a .h file.

// the Account SID from your Twilio account
const String TWILIO_ACCOUNT_SID = "";

// the Auth Token from your Twilio account
const String TWILIO_AUTH_TOKEN = "";

// your Twilio phone number, e.g., "+1 555-222-1212"
const String TWILIO_NUMBER = "+";

// the number to which the SMS should be sent, e.g., "+1 555-222-1212"
const String RECIPIENT_NUMBER = "+";

// a flag to indicate whether we've attempted to send the SMS yet or not
boolean attempted = false; 

int sensorSlidingDoor = 2;

void setup() {

  // for debugging, wait until a serial console is connected


  // prep sensor for input:
  pinMode(sensorSlidingDoor, INPUT_PULLUP);



void loop()
  int sensorState = digitalRead(sensorSlidingDoor);
  // only try to send the SMS if we haven't already sent it successfully

  if (sensorState == 1){
    Serial.println("Door open, running SendAnSMS...");
    // should get time door is open

      // we need a Process object to send a Choreo request to Temboo
      TembooChoreo SendSMSChoreo;
      // invoke the Temboo client
      // NOTE that the client must be reinvoked and repopulated with
      // appropriate arguments each time its run() method is called.
      // set Temboo account credentials

      // identify the Temboo Library choreo to run (Twilio > SMSMessages > SendSMS)

      // set the required choreo inputs
      // see 
      // for complete details about the inputs for this Choreo

      // the first input is a your AccountSID
      SendSMSChoreo.addInput("AccountSID", TWILIO_ACCOUNT_SID);
      // next is your Auth Token
      SendSMSChoreo.addInput("AuthToken", TWILIO_AUTH_TOKEN);
      // next is your Twilio phone number
      SendSMSChoreo.addInput("From", TWILIO_NUMBER);
      // next, what number to send the SMS to
      SendSMSChoreo.addInput("To", RECIPIENT_NUMBER);

      // finally, the text of the message to send
      SendSMSChoreo.addInput("Body", "Sliding door open at 8 Winding Way - matts arduino");
      // tell the Process to run and wait for the results. The 
      // return code (returnCode) will tell us whether the Temboo client 
      // was able to send our request to the Temboo servers
      unsigned int returnCode =;

      // a return code of zero (0) means everything worked
      if (returnCode == 0) {
          Serial.println("Success! SMS sent!");
      } else {
        // a non-zero return code means there was an error
        // read and print the error message
        while (SendSMSChoreo.available()) {
         char c =;
      // set the flag indicatine we've tried once.


Remove or comment out the line

" while(!Serial); "

That is waiting until it senses a full USB connection.
That should fix your issue.

Wow. Interesting Ballscrewbob. Will be testing this shortly and will share feedback. Many thanks.