We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Problem with Pachube feed using EEML Library
Page Index Toggle Pages: 1
Problem with Pachube feed using EEML Library (Read 1899 times)
Problem with Pachube feed using EEML Library
Jun 5th, 2010, 8:08am
 
Hi

I am having a problem with a Pachube feed in Processing being disrupted as a result  of a call to the Arduino.

The Arduino works fine independendently of the Pachube feed and the Pachube feed is fine independently of the Arduino. When I uncomment the statements within the if () blocks below the call to the Arduino seems to disconnect the Pachube feed and I get the following error:

############################################
Problem running DataIn...
java.lang.reflect.InvocationTargetException
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at eeml.DataIn.run(DataIn.java:260)
     at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
     at pachubeCollectDataUseData2.onReceiveEEML(pachubeCollectDataUseData2.java:66)
     ... 6 more


###########################################


##CODE######################################
import eeml.*;
import processing.serial.*;
import cc.arduino.*;        

float  data;
DataIn dIn;
Arduino arduino;
int ledPin10 =  10;
int ledPin11 =  11;
int ledPin12 = 12;
int average;


void setup(){
// set up DataIn object; indicate the URL you want, your Pachube API key, and how often you want it to update e.g. every 5 seconds

     dIn = new DataIn(this,"somePachubeFeedXML","MY_PACHUBE_KEY_HERE", 5000);
   
//print("this is the list of arduinos: ");
   //println(Arduino.list());
 arduino = new Arduino(this, Arduino.list()[0], 57600);
 arduino.pinMode(ledPin10, Arduino.OUTPUT);
 arduino.pinMode(ledPin11, Arduino.OUTPUT);
 arduino.pinMode(ledPin12, Arduino.OUTPUT);
}

void draw()
{
   // do whatever needs doing in the main loop
   
}

// onReceiveEEML is run every time your app receives back EEML that it has requested from a Pachube feed.
void onReceiveEEML(DataIn d){

   float myVariable = d.getValue(1); // get the value of the stream 1
    data = myVariable;
    int average = (int) myVariable;
println(average);

    if (average < 265) {
     //arduino.digitalWrite(ledPin10, Arduino.LOW); //problem emerges if this is called.
     //arduino.analogWrite (ledPin11, Arduino.LOW); //problem emerges if this is called.
     //arduino.analogWrite (ledPin12, Arduino.LOW); //problem emerges if this is called.
    }
   
    if (average > 265){
    // arduino.digitalWrite(ledPin10, Arduino.HIGH); //problem emerges if this is called.
     //arduino.digitalWrite(ledPin11, Arduino.HIGH); //problem emerges if this is called.
     //arduino.digitalWrite(ledPin12, Arduino.HIGH); //problem emerges if this is called.
    }

}

########################################

Any ideas would be much appreciated.
Thanks
Re: Problem with Pachube feed using EEML Library
Reply #1 - Jun 5th, 2010, 11:20am
 
i would probably use the onReceive method to set your variable (as a global variable, rather than just local) and use the main draw loop to control the arduino.
Page Index Toggle Pages: 1