2016-07-19 9 views
0

現在、Sparkfun esp2866 Wifi Shieldを使用してArduino Unoを通じてメッセージを送信しようとしています。私はすでにTwilioとTembooのアカウントを設定しています。 TembooとSparkfun esp2866シールドライブラリを使用して、以下のコードを生成しました。すべての個人情報が取り出されました。Esp8266 Sparkfun WifiシールドとArduinoを使用してSMSを送信するにはどうすればよいですか?

Tembooのすべてのアカウント情報を含む私のコードに他のファイルを含めていません。

私はプログラムを実行しようとすると、シールドは私のwifiネットワークに接続しますが、私の携帯電話にテキストメッセージを送信しません。私はIOT装置での作業経験があまりなく、誰かが手伝ってくれるかどうか疑問に思っていました。すべての入力をいただければ幸いです!

ありがとうございます!

#include <SoftwareSerial.h> 
#include <SparkFunESP8266WiFi.h> 
#include <Temboo.h> 
#include "TembooAccount.h" 

const char mySSID[] = "ssid "; 
const char myPSK[] = " password"; 

ESP8266Client client; 


int numRuns = 1; // Execution count, so this doesn't run forever 
int maxRuns = 10; 

void setup() 
{ 
    // Serial Monitor is used to control the demo and view 
    // debug information. 
    Serial.begin(9600); 
    Serial.println("Serial started"); 
    serialTrigger(F("Press any key to begin.")); 

    // initializeESP8266() verifies communication with the WiFi 
    // shield, and sets it up. 
    initializeESP8266(); 

    // connectESP8266() connects to the defined WiFi network. 
    connectESP8266(); 

    // displayConnectInfo prints the Shield's local IP 
    // and the network it's connected to. 
    displayConnectInfo(); 


} 

void loop() 
{ 
    if (numRuns <= maxRuns) { 
    Serial.println("Running SendSMS - Run #" + String(numRuns++)); 
    delay(1000); 
    TembooChoreo SendSMSChoreo(client); 

    // 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 
    String AuthTokenValue = ""; 
    SendSMSChoreo.addInput("AuthToken", AuthTokenValue); 
    String ToValue = ""; 
    SendSMSChoreo.addInput("To", ToValue); 
    String FromValue = ""; 
    SendSMSChoreo.addInput("From", FromValue); 
    String BodyValue = "Hello World"; 
    SendSMSChoreo.addInput("Body", BodyValue); 
    String AccountSIDValue = ""; 
    SendSMSChoreo.addInput("AccountSID", AccountSIDValue); 

    // Identify the Choreo to run 
    SendSMSChoreo.setChoreo("/Library/Twilio/SMSMessages/SendSMS"); 

    // Run the Choreo; when results are available, print them to serial 
    SendSMSChoreo.run(); 
    Serial.println("DONE!"); 
    while(SendSMSChoreo.available()) { 
     char c = SendSMSChoreo.read(); 
     Serial.print(c); 
    } 
    SendSMSChoreo.close(); 
    } 

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


void initializeESP8266() 
{ 
    // esp8266.begin() verifies that the ESP8266 is operational 
    // and sets it up for the rest of the sketch. 
    // It returns either true or false -- indicating whether 
    // communication was successul or not. 
    // true 
    int test = esp8266.begin(); 
    if (test != true) 
    { 
    Serial.println(F("Error talking to ESP8266.")); 
    errorLoop(test); 
    } 
    Serial.println(F("ESP8266 Shield Present")); 
} 

void connectESP8266() 
{ 
    // The ESP8266 can be set to one of three modes: 
    // 1 - ESP8266_MODE_STA - Station only 
    // 2 - ESP8266_MODE_AP - Access point only 
    // 3 - ESP8266_MODE_STAAP - Station/AP combo 
    // Use esp8266.getMode() to check which mode it's in: 
    int retVal = esp8266.getMode(); 
    if (retVal != ESP8266_MODE_STA) 
    { // If it's not in station mode. 
    // Use esp8266.setMode([mode]) to set it to a specified 
    // mode. 
    retVal = esp8266.setMode(ESP8266_MODE_STA); 
    if (retVal < 0) 
    { 
     Serial.println(F("Error setting mode.")); 
     errorLoop(retVal); 
    } 
    } 
    Serial.println(F("Mode set to station")); 

    // esp8266.status() indicates the ESP8266's WiFi connect 
    // status. 
    // A return value of 1 indicates the device is already 
    // connected. 0 indicates disconnected. (Negative values 
    // equate to communication errors.) 
    retVal = esp8266.status(); 
    if (retVal <= 0) 
    { 
    Serial.print(F("Connecting to ")); 
    Serial.println(mySSID); 
    // esp8266.connect([ssid], [psk]) connects the ESP8266 
    // to a network. 
    // On success the connect function returns a value >0 
    // On fail, the function will either return: 
    // -1: TIMEOUT - The library has a set 30s timeout 
    // -3: FAIL - Couldn't connect to network. 
    retVal = esp8266.connect(mySSID, myPSK); 
    if (retVal < 0) 
    { 
     Serial.println(F("Error connecting")); 
     errorLoop(retVal); 
    } 
    } 
} 

void displayConnectInfo() 
{ 
    char connectedSSID[24]; 
    memset(connectedSSID, 0, 24); 
    // esp8266.getAP() can be used to check which AP the 
    // ESP8266 is connected to. It returns an error code. 
    // The connected AP is returned by reference as a parameter. 
    int retVal = esp8266.getAP(connectedSSID); 
    if (retVal > 0) 
    { 
    Serial.print(F("Connected to: ")); 
    Serial.println(connectedSSID); 
    } 

    // esp8266.localIP returns an IPAddress variable with the 
    // ESP8266's current local IP address. 
    IPAddress myIP = esp8266.localIP(); 
    Serial.print(F("My IP: ")); Serial.println(myIP); 
} 



// errorLoop prints an error code, then loops forever. 
void errorLoop(int error) 
{ 
    Serial.print(F("Error: ")); Serial.println(error); 
    Serial.println(F("Looping forever.")); 
    for (;;) 
    ; 
} 

// serialTrigger prints a message, then waits for something 
// to come in from the serial port. 
void serialTrigger(String message) 
{ 
    Serial.println(); 
    Serial.println(message); 
    Serial.println(); 
    while (!Serial.available()) 
    ; 
    while (Serial.available()) 
    Serial.read(); 
} 

答えて

1

私はTembooで働いています。

正式にESP8266をサポートしていませんが、TembooにESP8266を使用させるためのフォーラムの記事がいくつか見つかりました。それでも解決しない場合は

http://www.esp8266.com/viewtopic.php?p=24019

https://forum.arduino.cc/index.php?topic=337186.0

は、Temboo Supportに連絡すること自由に感じ、私たちはあなたのために間違って何が起こっているかを把握助けるために全力を尽くします:ここに行きます。あなたはこれらのファイルには「AVR/pgmspace.h」のすべての回出てくる変更する必要が

\Arduino\libraries\Temboo\src\Temboo.cpp 

\Arduino\libraries\Temboo\src\utility\ 
--ChoreoInputFormatter 
--ChoreoOutputFormatter 
--ChoreoPresetFormatter 
--TembooSession 
--tmbhmac 
--tmbmd5 

あなたが知っておく必要がある情報の重要な部分では、次のTembooライブラリファイルを変更する必要があるということですそれを "pgmspace.h"に変更します。

+1

ありがとうございます - あなたのコメントに基づいて元の回答を更新しました。 –

関連する問題