Show Posts
Pages: [1] 2
1  Products / Arduino Yún / Displaying Temboo data on a web page on: February 01, 2014, 10:40:50 am
Hello,

I'm trying to print the contents of a Temboo choreo to a web page and I'm not having any luck. The code just below works fine when I run it but it's being printed out to the Serial Monitor:

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

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

void setup() {
  Serial.begin(9600);
  
  // For debugging, wait until the serial console is connected.
  delay(4000);
  while(!Serial);
  Bridge.begin();
}
void loop()
{
  if (numRuns <= maxRuns) {
    Serial.println("Running GetRecentActivities - Run #" + String(numRuns++));
    
    TembooChoreo GetRecentActivitiesChoreo;

    // Invoke the Temboo client
    GetRecentActivitiesChoreo.begin();
    
    // Set Temboo account credentials
    GetRecentActivitiesChoreo.setAccountName(TEMBOO_ACCOUNT);
    GetRecentActivitiesChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
    GetRecentActivitiesChoreo.setAppKey(TEMBOO_APP_KEY);
    
    // Set Choreo inputs
    GetRecentActivitiesChoreo.addInput("AccessToken", "xxxxxxx");
    GetRecentActivitiesChoreo.addInput("AccessTokenSecret", "xxxxx");
    GetRecentActivitiesChoreo.addInput("ConsumerSecret", "xxxxxxx");
    GetRecentActivitiesChoreo.addInput("ConsumerKey", "xxxxxxx");
    
    // Identify the Choreo to run
    GetRecentActivitiesChoreo.setChoreo("/Library/Fitbit/Activities/GetRecentActivities");
    
    // Set filter for response
    GetRecentActivitiesChoreo.addOutputFilter("name", "/[1]/name", "Response");
    GetRecentActivitiesChoreo.addOutputFilter("duration", "/[1]/duration", "Response");    
    
    // Run the Choreo; when results are available, print them to serial
    GetRecentActivitiesChoreo.run();
    
    while(GetRecentActivitiesChoreo.available()) {
      char c = GetRecentActivitiesChoreo.read();
      Serial.print(c);
    }
    GetRecentActivitiesChoreo.close();

  }

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

But when I bring in the code from TemperatureWebPanel to display on a webpage, I break and it seems like in the loop, 'if (client) {' is never getting caught, so nothing happens. Am I implementing this correctly? (lines with '// added' have been brought in from TemperatureWebPanel).

Code:
#include <Bridge.h>
#include <Temboo.h>
#include <YunServer.h>       // added
#include <YunClient.h>        // added
#include "TembooAccount.h" // contains Temboo account information, as described below

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

YunServer server;       // added

void setup() {
  Serial.begin(9600);
  
  // For debugging, wait until the serial console is connected.
  delay(4000);
  while(!Serial);
  Bridge.begin();
  
  server.listenOnLocalhost();            //added
  server.begin();            //added
}
void loop()
{
  YunClient client = server.accept();            //added
  
  
  
  
    // There is a new client?               // everything in this if statement has been added
  if (client) {
    // read the command
    String command = client.readString();
    command.trim();        //kill whitespace
    Serial.println(command);
    // is "temperature" command?
    if (command == "temperature") {

      // print the temperature:
      client.print("Current time on the Yún: ");
      client.println("");
      client.print("<br>Current temperature: ");
      client.print("");
      client.print(" degrees C");
      client.print("<br>This sketch has been running since ");
      client.print("");
      client.print("<br>Hits so far: ");
      client.print("");
    }

  
    if (numRuns <= maxRuns) {
      Serial.println("Running GetRecentActivities - Run #" + String(numRuns++));
      
      TembooChoreo GetRecentActivitiesChoreo;
  
      // Invoke the Temboo client
      GetRecentActivitiesChoreo.begin();
      
      // Set Temboo account credentials
      GetRecentActivitiesChoreo.setAccountName(TEMBOO_ACCOUNT);
      GetRecentActivitiesChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
      GetRecentActivitiesChoreo.setAppKey(TEMBOO_APP_KEY);
      
      // Set Choreo inputs
      GetRecentActivitiesChoreo.addInput("AccessToken", "xxxxxxx");
      GetRecentActivitiesChoreo.addInput("AccessTokenSecret", "xxxxxxx");
      GetRecentActivitiesChoreo.addInput("ConsumerSecret", "xxxxxxx");
      GetRecentActivitiesChoreo.addInput("ConsumerKey", "xxxxxxx");
      
      // Identify the Choreo to run
      GetRecentActivitiesChoreo.setChoreo("/Library/Fitbit/Activities/GetRecentActivities");
      
      // Set filter for response
      GetRecentActivitiesChoreo.addOutputFilter("name", "/[1]/name", "Response");
      GetRecentActivitiesChoreo.addOutputFilter("duration", "/[1]/duration", "Response");    
      
      // Run the Choreo; when results are available, print them to serial
      GetRecentActivitiesChoreo.run();
      
      while(GetRecentActivitiesChoreo.available()) {
        char c = GetRecentActivitiesChoreo.read();
        client.print(c);
      }
      client.println("");
      
      GetRecentActivitiesChoreo.close();
  
    }
  }
    // Close connection and free resources.
    client.stop();

  delay(50); // Poll every 50ms
}
2  Using Arduino / Microcontrollers / Displaying Temboo data on a web page on: February 01, 2014, 10:31:52 am
Hello,

I'm trying to print the contents of a Temboo choreo to a web page and I'm not having any luck. The code just below works fine when I run it but it's being printed out to the Serial Monitor:

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

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

void setup() {
  Serial.begin(9600);
  
  // For debugging, wait until the serial console is connected.
  delay(4000);
  while(!Serial);
  Bridge.begin();
}
void loop()
{
  if (numRuns <= maxRuns) {
    Serial.println("Running GetRecentActivities - Run #" + String(numRuns++));
    
    TembooChoreo GetRecentActivitiesChoreo;

    // Invoke the Temboo client
    GetRecentActivitiesChoreo.begin();
    
    // Set Temboo account credentials
    GetRecentActivitiesChoreo.setAccountName(TEMBOO_ACCOUNT);
    GetRecentActivitiesChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
    GetRecentActivitiesChoreo.setAppKey(TEMBOO_APP_KEY);
    
    // Set Choreo inputs
    GetRecentActivitiesChoreo.addInput("AccessToken", "xxxxxxx");
    GetRecentActivitiesChoreo.addInput("AccessTokenSecret", "xxxxx");
    GetRecentActivitiesChoreo.addInput("ConsumerSecret", "xxxxxxx");
    GetRecentActivitiesChoreo.addInput("ConsumerKey", "xxxxxxx");
    
    // Identify the Choreo to run
    GetRecentActivitiesChoreo.setChoreo("/Library/Fitbit/Activities/GetRecentActivities");
    
    // Set filter for response
    GetRecentActivitiesChoreo.addOutputFilter("name", "/[1]/name", "Response");
    GetRecentActivitiesChoreo.addOutputFilter("duration", "/[1]/duration", "Response");    
    
    // Run the Choreo; when results are available, print them to serial
    GetRecentActivitiesChoreo.run();
    
    while(GetRecentActivitiesChoreo.available()) {
      char c = GetRecentActivitiesChoreo.read();
      Serial.print(c);
    }
    GetRecentActivitiesChoreo.close();

  }

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

But when I bring in the code from TemperatureWebPanel to display on a webpage, I break and it seems like in the loop, 'if (client) {' is never getting caught, so nothing happens. Am I implementing this correctly? (lines with '// added' have been brought in from TemperatureWebPanel).

Code:
#include <Bridge.h>
#include <Temboo.h>
#include <YunServer.h>       // added
#include <YunClient.h>        // added
#include "TembooAccount.h" // contains Temboo account information, as described below

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

YunServer server;       // added

void setup() {
  Serial.begin(9600);
  
  // For debugging, wait until the serial console is connected.
  delay(4000);
  while(!Serial);
  Bridge.begin();
  
  server.listenOnLocalhost();            //added
  server.begin();            //added
}
void loop()
{
  YunClient client = server.accept();            //added
  
  
  
  
    // There is a new client?               // everything in this if statement has been added
  if (client) {
    // read the command
    String command = client.readString();
    command.trim();        //kill whitespace
    Serial.println(command);
    // is "temperature" command?
    if (command == "temperature") {

      // print the temperature:
      client.print("Current time on the Yún: ");
      client.println("");
      client.print("<br>Current temperature: ");
      client.print("");
      client.print(" degrees C");
      client.print("<br>This sketch has been running since ");
      client.print("");
      client.print("<br>Hits so far: ");
      client.print("");
    }

  
    if (numRuns <= maxRuns) {
      Serial.println("Running GetRecentActivities - Run #" + String(numRuns++));
      
      TembooChoreo GetRecentActivitiesChoreo;
  
      // Invoke the Temboo client
      GetRecentActivitiesChoreo.begin();
      
      // Set Temboo account credentials
      GetRecentActivitiesChoreo.setAccountName(TEMBOO_ACCOUNT);
      GetRecentActivitiesChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
      GetRecentActivitiesChoreo.setAppKey(TEMBOO_APP_KEY);
      
      // Set Choreo inputs
      GetRecentActivitiesChoreo.addInput("AccessToken", "xxxxxxx");
      GetRecentActivitiesChoreo.addInput("AccessTokenSecret", "xxxxxxx");
      GetRecentActivitiesChoreo.addInput("ConsumerSecret", "xxxxxxx");
      GetRecentActivitiesChoreo.addInput("ConsumerKey", "xxxxxxx");
      
      // Identify the Choreo to run
      GetRecentActivitiesChoreo.setChoreo("/Library/Fitbit/Activities/GetRecentActivities");
      
      // Set filter for response
      GetRecentActivitiesChoreo.addOutputFilter("name", "/[1]/name", "Response");
      GetRecentActivitiesChoreo.addOutputFilter("duration", "/[1]/duration", "Response");    
      
      // Run the Choreo; when results are available, print them to serial
      GetRecentActivitiesChoreo.run();
      
      while(GetRecentActivitiesChoreo.available()) {
        char c = GetRecentActivitiesChoreo.read();
        client.print(c);
      }
      client.println("");
      
      GetRecentActivitiesChoreo.close();
  
    }
  }
    // Close connection and free resources.
    client.stop();

  delay(50); // Poll every 50ms
}
3  Products / Arduino Yún / Re: Yun - Can't turn LED on/off through browser on: January 27, 2014, 11:10:10 am
I see. The protocol needs to be defined in the sketch, correct?
4  Products / Arduino Yún / Re: Yun with Arduino Motor Shield R3 on: January 21, 2014, 12:53:30 pm
I worked on a different setup, using the Yum as web server and wifi bridge to another Arduino (mega in my case) equipped with the shield. I drive everything via Yun that communicate via I2C to the mega. I had 2 separated power supply lines. It worked very well so far.

I tried the same setup; Yun as the Master and Mega as the slave with the Motor shield on the Mega. EasyTransferI2C_NL was the library I was using for I2C communication between the two boards.  I found there was a pin conflict between pin 3 on the Yun (the SCL pin for I2C) and pin 3 on the Mega(is the PWM for motor B on the motor shield).

My application would crash and I believe because while the Yun is sending I2C data through it's pin 3, I'm stomping on it every time I change the PWM on my motor.

So if you only need one motor, this wouldn't be an issue because you're not using pin 3 from the Mega. So I don't see how this can be done if you need two motors. I'm about to try the 'cutting off the VIN pin on the Mega' trick to get it to play nice with my Yun.

Eric
5  Products / Arduino Yún / Yun - Can't turn LED on/off through browser on: January 13, 2014, 10:46:22 pm
Hello,
I'm just trying to send the url "http://ericsyun.local/arduino/digital/10/1" in my Chrome browser. My Yun is working fine I believe because I can display a temperature variable in my webpage, but I want to be able to turn a pin on and off as described in the examples and it's not working. My password protection is turned off on the API.

Here's my html:
Code:

<a href="http://ericsyun.local/arduino/digital/10/1">Turn Pin 10 on</a><BR>
<a href="http://ericsyun.local/arduino/digital/10/0">Turn Pin 10 off</a><BR>
I understand why a blank page is being returned, but not why pin10 isn't going hi or low. This makes me wonder if I'm implementing the url correctly. Unfortunately, there aren't too many examples that show the HTML side of things.

Thanks,
Eric
6  Using Arduino / Networking, Protocols, and Devices / Re: Two nRF24L01+/Arduino UNOs don't talk to each other on: December 17, 2013, 07:47:36 pm
Hey hyp3rkyd,

How exactly did you connect the 3.3v to the nRF? Did you go 5v out of the Arduino into the external 3.3v regulator and then into the nRF? If not, what power source did you go off of?

Thanks,
Eric
7  Using Arduino / Project Guidance / Re: Trouble Connecting to Web Server with WifiShield Example on: June 26, 2013, 10:57:13 am
Jairo,

I spoke too soon, yes I initially got it to work with the new wifi shield and I didn't try the old one with the new libraries. Here's a link to the libraries https://github.com/arduino/Arduino/tree/master/libraries. Make sure you update the SPI library along with the WIFI library.

The problem I have now is that it's works ok for the first two/three requests and then it just hangs afterwards and I have to reset it. I need something much more reliable and so I'm working on a Raspberry Pi.

Good luck. Let me know if you get it stable.

Eric
8  Using Arduino / Project Guidance / Re: Trouble Connecting to Web Server with WifiShield Example on: June 21, 2013, 11:38:29 pm
I got mine working. After spending two night troubleshooting, I got another WiFi Shield (there's a MicroCenter just down the road!) to start fresh.
Before I plugged it in, I went and got the latest GitHub libraries of Wifi and SPI and overwrote them in the Arduino IDE Library directory. Cranked up the WifiWebServer.ino sketch, changed the SSID, password and port and it worked the first time!

Code:
Attempting to connect to SSID: myNetwork
SSID: myNetwork
IP Address: 192.168.1.x
signal strength (RSSI):-26 dBm
new client
GET / HTTP/1.1
Host: 192.168.1.x:8080
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36
Accept-Encoding: gzip,deflate
Accept-Language: en-US,en;q=0.8

client disonnected

Using:
Arduino R3
Arduino Wifi Shield R3
Arduino IDE v1.0.5

I didn't have to update the firmware on anything either. Let me know if you need any other info and I'll gladly get it for you.

Eric
9  Using Arduino / Project Guidance / Re: [SOLVED] Uno & WiFi Shield on: June 19, 2013, 10:28:13 pm
restarted my router and I'm still not getting the connection request.
10  Community / Products and Services / Re: Wrobot / Emartee / Ywrobot relay board... on: May 07, 2012, 11:54:25 pm
Hey Terry,
I'm so glad I found this thread. Your website was everything I was looking for. I'm somewhat new to Arduino and brand new to Arduino relay breakout boards. Since the documentation is scarce on the Relay Module from SainSmart, your tutorial was key in understanding how to move forward with this piece so thank you so much!

There's a Sparkfun tutorial http://www.sparkfun.com/tutorials/119 that picks up from where you left off as far as creating a safe connection to a wall outlet. I don't have all of the parts with me tonight but I now know what to get.

So thanks again and I'm going to be combing through your website for sure!

Eric
11  Using Arduino / Project Guidance / Re: Ping)) Sensor Problem on: March 26, 2012, 10:13:47 am
But those specs you posted say "Operating Voltage 5V". I guess I'm not sure what the difference is between "Operating Voltage" and "Input Voltage (limits)"
12  Using Arduino / Project Guidance / Ping)) Sensor Problem on: March 25, 2012, 09:59:29 pm
Hey All,
I just got my Ping))) sensor in the mail and hooked it up. Everything seemed to work ok at my desk but when I took it downstairs to impress my wife with it, it didn't quite work. I've got 3 led's connected to it to show the distance detected; red light is on when the object is < 12" away from the sensor, yellow light shows 12" - 36" and green light is on when sensor detects +36" distance. I'm printing out the distance to the Serial port in my code also.

So when this is powered through my usb cable, things work great but when I power it through my 5v power supply that came with the Arduino Mega, everything works except for the green light (the one that detects +36"). The red and yellow lights work but the green doesn't.

Here's a video of the problem:

Here's the code:
Code:
int trigPin = 2;
int echoPin = 3;
int redPin = 10;
int yellowPin = 11;
int greenPin = 12;

void setup() {
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
}

void loop()
{
  // establish variables for duration of the ping,
  // and the distance result in inches and centimeters:
  long duration, inches, cm;

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);

  // convert the time into a distance
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
 
  if(inches < 12) {
   
    digitalWrite(redPin, HIGH);
    digitalWrite(yellowPin, LOW);
    digitalWrite(greenPin, LOW);
 
  } else if(inches > 11 && inches < 36) {
   
    digitalWrite(redPin, LOW);
    digitalWrite(yellowPin, HIGH);
    digitalWrite(greenPin, LOW);   
 
  } else if(inches > 35) {
   
    digitalWrite(redPin, LOW);
    digitalWrite(yellowPin, LOW);
    digitalWrite(greenPin, HIGH);
 
  } else {
    // There's an error so have all of them come on.
    digitalWrite(redPin, HIGH);
    digitalWrite(yellowPin, HIGH);
    digitalWrite(greenPin, HIGH);
  }
 
  Serial.print(inches);
  Serial.print("in, ");
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();
 
  delay(100);
}

long microsecondsToInches(long microseconds)
{
  // According to Parallax's datasheet for the PING))), there are
  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
  // second).  This gives the distance travelled by the ping, outbound
  // and return, so we divide by 2 to get the distance of the obstacle.
  // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
  return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds)
{
   //The speed of sound is 340 m/s or 29 microseconds per centimeter.
   //The ping travels out and back, so to find the distance of the
   //object we take half of the distance travelled.
  return microseconds / 29 / 2;
}

Here's something else I just discovered:
I disconnected my Mega and hooked this setup up to my Ardiono Nano. When I hook it up to my computer via mini usb, it works and when I hook it up through a mini usb power cable to the wall, it works! So this tells me it's got something to do with being hooked up to the Mega using external power, right?
13  Using Arduino / Programming Questions / Re: Rolling through LED's with a potentiometer on: March 13, 2012, 09:59:14 am
nevermind AWOL; just found this: http://arduino.cc/en/Reference/Map
14  Using Arduino / Programming Questions / Re: Rolling through LED's with a potentiometer on: March 13, 2012, 09:58:05 am
@PaulS - I'm doing this on an Ardweeny so I didn't see that 'tx' label that's right there on my mega. Thank you!
@AWOL - cool, I looked at the map method and I'll see how I can utilize this to my advantage. Shorter in the fact that I could minimize my if statements? I'll try to find some examples. Thanks again for your help.
15  Using Arduino / Programming Questions / Re: Rolling through LED's with a potentiometer on: March 13, 2012, 09:36:31 am
Thanks dxw00d, forgot about that! My setup() now looks like this:
Code:
void setup() {
  Serial.begin(9600);
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
}
When I turn the pot, the other LED's turn on, however, my first LED is still constantly on. Not sure why because I'm setting it to LOW in the if statements.

AWOL - I have seen the map function. Is that required for this example to work?
Pages: [1] 2