0

最近、Arduino Yun を入手してから Temboo を使用していますが、Choreos を組み合わせてデータを取得および投稿する際に問題が発生しています。

私は Yahoo GetWeatherByAddress Choreo を使用しており、必要な個々の値を Xively フィードに投稿しようとしています。Xively Write Choreo を使用し、FeedData を JSON 形式で入力しています。

これまでのところ、一度に 2 つの値 (湿度と圧力) を投稿することにある程度成功しています。残念ながら、私はこれ以上のものを使用したいと考えており、湿度、温度、気象条件 (晴天、強風など) と、ブレッドボードからの LDR の読み取りが必要です。したがって、10 秒ごとにループし、それらの値をすべて読み取り、Xively に投稿します。コメントを外した温度値以上のものがある場合、温度値はシリアル モニタへの出力にも問題があるようです。また、プロセス全体を実行するわけではありません (成功の場合は Http 200 を返します)。値を送信し、次の値のセットが取得されるのを「待機」するだけです。ここでどこが間違っていますか?

      /*
    YahooWeather

    This example code is in the public domain.
  */

  #include <Bridge.h>
  #include <Temboo.h>
  #include "TembooAccount.h" // contains Temboo account information

  // the address for which a weather forecast will be retrieved
  String ADDRESS_FOR_FORECAST = "Plymouth, United Kingdom";

  int numRuns = 1;   // execution count, so that this doesn't run forever
  int maxRuns = 10;  // max number of times the Yahoo WeatherByAddress Choreo should be run
  String pData;
  String qData;
  String rData;
  String tData;
  String cData;



  void setup() {
    Serial.begin(9600);

    // for debugging, wait until a serial console is connected
    delay(4000);
    while(!Serial);
    Bridge.begin();
    pinMode(A0, INPUT);
    pinMode(13, OUTPUT);


  }

  void loop()
  {
      if (numRuns <= maxRuns) {
      int sensorValue = analogRead(A0);

      if (sensorValue < 100) { 
        digitalWrite(13,HIGH);
        delay(1000);
        digitalWrite(13,LOW);
      }



    // while we haven't reached the max number of runs...


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

      TembooChoreo WriteDataChoreo;

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

      // Set Temboo account credentials
      WriteDataChoreo.setAccountName(TEMBOO_ACCOUNT);
      WriteDataChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
      WriteDataChoreo.setAppKey(TEMBOO_APP_KEY);




      // print status
      Serial.println("Running GetWeatherByAddress - Run #" + String(numRuns++) + "...");

      // create a TembooChoreo object to send a Choreo request to Temboo
      TembooChoreo GetWeatherByAddressChoreo;


      // invoke the Temboo client
      GetWeatherByAddressChoreo.begin();


      // add your temboo account info
      GetWeatherByAddressChoreo.setAccountName(TEMBOO_ACCOUNT);
      GetWeatherByAddressChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
      GetWeatherByAddressChoreo.setAppKey(TEMBOO_APP_KEY);



      // set the name of the choreo we want to run
      GetWeatherByAddressChoreo.setChoreo("/Library/Yahoo/Weather/GetWeatherByAddress");

      // set choreo inputs; in this case, the address for which to retrieve weather data
      // the Temboo client provides standardized calls to 100+ cloud APIs
      GetWeatherByAddressChoreo.addInput("Address", ADDRESS_FOR_FORECAST);



      // add an output filter to extract the name of the city.
       GetWeatherByAddressChoreo.addOutputFilter("pressure", "/rss/channel/yweather:atmosphere/@pressure", "Response");
         GetWeatherByAddressChoreo.addOutputFilter("humidity", "/rss/channel/yweather:atmosphere/@humidity", "Response");
          GetWeatherByAddressChoreo.addOutputFilter("text", "/rss/channel/item/yweather:condition/@text", "Response");
           // GetWeatherByAddressChoreo.addOutputFilter("temperature", "/rss/channel/item/yweather:condition/@temp", "Response");  //    
      // add an output filter to extract the current temperature





      // add an output filter to extract the date and time of the last report.

      // run the choreo 
      GetWeatherByAddressChoreo.run();

      // parse the results and print them to the serial monitor
      while(GetWeatherByAddressChoreo.available()) {

          // read the name of the next output item
         String name = GetWeatherByAddressChoreo.readStringUntil('\x1F');
         name.trim(); // use “trim” to get rid of newlines

          // read the value of the next output item
          String data = GetWeatherByAddressChoreo.readStringUntil('\x1E');
          data.trim(); // use “trim” to get rid of newlines


        if (name == "humidity") {

               qData = data;

               Serial.println("The humidity is " + qData);

           }
            else if (name == "temperature") {

             tData = data;

               Serial.println("The temperature is " + tData);

           } 

           else if (name == "pressure") {

               rData = data;

               Serial.println("The pressure is " + rData);

           } 

           else if (name == "text") {


             cData = data;
               Serial.println("The code is " + cData);

           } 


       }

    WriteDataChoreo.addInput("FeedID", "1508368369");
    WriteDataChoreo.addInput("APIKey", "6Z4tvi6jUOC0VhFkgngijR3bZWMXr2NNu1PHl4Js0hHGqE6C");
    // WriteDataChoreo.addInput("FeedData", "{\"version\":\"1.0.0\",\"datastreams\":[ {\"id\" : \"Pressure\",\"current_value\" : \"" + rData + "\"} ,{\"id\" : \"Humidity\",\"current_value\" : \"" + qData + "\"} ,{\"id\" : \"Conditions\",\"current_value\" : \"" + cData + "\"}]}"); 
    WriteDataChoreo.addInput("FeedData", "{\"version\":\"1.0.0\",\"datastreams\":[{\"id\":\"Humidity\",\"current_value\":\""+qData+"\"},{\"id\":\"Pressure\",\"current_value\":\""+rData+"\"},{\"id\":\"Conditions\",\"current_value\":\""+cData+"\"},{\"id\":\"Temp\",\"current_value\":\""+tData+"\"}]}");
     // Identify the Choreo to run




     // Identify the Choreo to run
     WriteDataChoreo.setChoreo("/Library/Xively/ReadWriteData/WriteData");

     // Run the Choreo; when results are available, print them to serial
      WriteDataChoreo.run();

           while(WriteDataChoreo.available()) {
        char c = WriteDataChoreo.read();
        //Serial.print(c);



           }

           while(GetWeatherByAddressChoreo.available()) {
        char c = GetWeatherByAddressChoreo.read();
        //Serial.print(c);



           }
      WriteDataChoreo.close();
      GetWeatherByAddressChoreo.close();

      Serial.println("");
      Serial.println("Waiting...");
      Serial.println("");
      delay(10000); // wait 30 seconds between GetWeatherByAddress calls
    }
4

1 に答える 1

2

天望で働いています。この問題は Temboo サポートを通じて既に解決されていると思いますので、後世のためにここで回答します。

通常、スケッチが断続的に動作し、コードを変更していない場合は、RAM が不足している可能性があります (リソースに制約のあるデバイスでよくある問題)。ボードの RAM が不足すると、Yun の 32U4 側で Choreo 入力データが上書きされて破損します。あなたのスケッチはおそらくRAMの制限に達しています。これは、関連する文字列データの量に応じて、機能する場合と機能しない場合がある理由を説明しています.

説明されているように、変更されない入力 (Temboo クレデンシャル、Xively クレデンシャル、検索しているアドレス、その他の静的文字列) を Linino 側に保存されている設定ファイルに入れることで、RAM を解放できます。以下のリンクで:

https://temboo.com/arduino/using-settings-files

それでも十分なメモリが解放されない場合は、不要な Serial または Console print ステートメントを削除することで、さらにメモリを解放できます。

うまくいけば、これはあなたが見ている問題を解決するのに役立ちます. そうでない場合はお知らせください。引き続き調査いたします。

最後に、スケッチが使用しているメモリ量を確認する方法に関する情報を次に示します。

http://jeelabs.org/2011/05/22/atmega-memory-use/

がんばれ、コーマック

于 2014-03-19T14:49:03.613 に答える