Using temboo to send a variable SMS?

Hey Friends!

I’m using an HTU21D sensor with Temboo to send a text to my cell phone when the temperature/humidity go past a certain amount… My question for ya’ll pertains to what is contained in the “body” of the text that is sent to my cell phone. I would like to send something like “the temperature is out of bounds and XX (<<<< a variable) degrees”. I’m not sure how to add a numerical variable into my code here.

The line in particular that needs addressing is:

SendSMSChoreo.addInput(“Body”, “temp out of bounds”);

Thanks!

Z

#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information, as described below
#include <Wire.h>
#include "SparkFunHTU21D.h"

int numRuns = 1;   // Execution count, so this doesn't run forever
int maxRuns = 10;   // Maximum number of times the Choreo should be executed

//Create instance of sensor
HTU21D myHumidity;

void setup() {
  Serial.begin(9600);
  
  // For debugging, wait until the serial console is connected
  delay(4000);
 Bridge.begin();
 myHumidity.begin();
}

void loop() {
  
  float humd = myHumidity.readHumidity();
  float temp = myHumidity.readTemperature();
  
  if (humd >= 30) { 
  if (numRuns <= maxRuns) {
    Serial.println("Running SendSMS - Run #" + String(numRuns++));
    
    TembooChoreo SendSMSChoreo;

    // Invoke the Temboo client
    SendSMSChoreo.begin();

    // Set Temboo account credentials
    SendSMSChoreo.setAccountName(TEMBOO_ACCOUNT);
    SendSMSChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
    SendSMSChoreo.setAppKey(TEMBOO_APP_KEY);
    
    // Set Choreo inputs
    SendSMSChoreo.addInput("AuthToken", "XXXXXX");
    SendSMSChoreo.addInput("Body", "temp out of bounds");
    SendSMSChoreo.addInput("To", "+XXXXXXXXXXX");
    SendSMSChoreo.addInput("AccountSID", "XXXXXXXX");
    SendSMSChoreo.addInput("From", "+11111111111");
    
    // Identify the Choreo to run
    SendSMSChoreo.setChoreo("/Library/Twilio/SMSMessages/SendSMS");
    
    // Run the Choreo; when results are available, print them to serial
    SendSMSChoreo.run();
    
    while(SendSMSChoreo.available()) {
      char c = SendSMSChoreo.read();
      Serial.print(c);
    }
    SendSMSChoreo.close();
  }

  Serial.println("Waiting...");
  delay(30000); // wait 30 seconds between SendSMS calls
}
}

Convert your 'variable' to a string, append it to the end of the constant text and pass that to the 'SendSMSChoreo.addInput' function?

Hi there, I work for Temboo.

dannable is right, you just need to convert the temperature variable to a string and append it to the text String. You should be able to do something like this:

String bodyValue = "the temperature is out of bounds and " + String(temp) + " degrees";
SendSMSChoreo.addInput("Body", bodyValue);

If you have any questions, feel free to contact us at https://www.temboo.com/contact - we're always happy to help.