xively / xively_arduino

A library for Arduino to make it easier to talk to Xively™
https://xively.com/dev/libraries/
101 stars 67 forks source link

To slow to perform action on an Arduino after I change a value on Xively #13

Closed roquito closed 11 years ago

roquito commented 11 years ago

When I manually log in to Xively and make a change in one of my tags, it is supposed to turn on an LED in my Arduino, I am using the method below to read the value of the tag, but sometimes it can take up to 4 seconds for the LED to reflect the new value.

I am new with Xively, can anyone point me in the right direction and tell me if there is another method that I can use to update the LED in real time?

''' void loop() { ret = xivelyclient.get(feed, xivelyKey); Serial.println("THE ABOVE PRODUCES A LATENCY OF ABOUT 2 SECONDS"); if (ret > 0) { outputtoled = feed[0].getFloat(); analogWrite(ledpin, outputtoled); }

}

'''

errordeveloper commented 11 years ago

See #1.

roquito commented 11 years ago

errordeveloper, thanks for helping. I am not having the #1 issue anymore. It is not taking a minute to read values, it is taking about 3 seconds but that is still too long for this application. What I am looking for is a faster way of getting the data to the Arduino, all I need is a single digit to tell the Arduino to activate a LED. Do you know if there is a way to push the data from Xively to the Arduino instead of the Arduino looping and doing an xivelyclient.get() indefinitely?

chut commented 11 years ago

Roquito, Maybe try using our MQTT server! It's design for doing near real time low overhead socket communications.

Here is an example of using it on Arduino, you will need the PubSub library for Arduino: https://gist.github.com/chut/7011078

roquito commented 11 years ago

Great chut, looks promising, I will definitely test it to see what kind of speeds I get.

roquito commented 11 years ago

Is there official documentation that I can read up on while I wait on my Yun to arrive later this week?

roquito commented 11 years ago

@chut I got my Arduino Yun and I am a bit frustrated at how they setup the thing. The Arduino portion does not seem to be connected to the Internet itself but rather it needs to talk to the Linux microprocessor, which IS connected to the Internet via WIFI. In other words, the nice example you sent me cannot be implemented directly on the Arduino as it never sees the connection. It appears that the easiest way to accomplish what I want is to use a middleman: Temboo.com.

Evidently, Temboo can't do MQTT to Xively, it only supports Triggers, my question to you is, Aren't Triggers fast to? if not, do you see a way to use MQTT on the Yun?

Thanks!

errordeveloper commented 11 years ago

You can write a program to run on Linux using Mosquito client... This really beyond the scope here, you should ask on stackoverflow.com. Also, keep in mind that there are many ways to accomplish this. You could probably try doing it in Python, but it might be a bit slow... It really depends on your skills. On 19 Oct 2013 21:44, "Roquito" notifications@github.com wrote:

@chut https://github.com/chut I got my Arduino Yun and I am a bit frustrated at how they setup the thing. The Arduino portion does not seem to be connected to the Internet itself but rather it needs to talk to the Linux microprocessor, which IS connected to the Internet via WIFI. In other words, the nice example you sent me cannot be implemented directly on the Arduino as it never sees the connection. It appears that the easiest way to accomplish what I want is to use a middleman: Temboo.com.

Evidently, Temboo can't do MQTT to Xively, it only supports Triggers, my question to you is, Aren't Triggers fast to? if not, do you see a way to use MQTT on the Yun?

Thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/xively/xively_arduino/issues/13#issuecomment-26658465 .

roquito commented 11 years ago

@chut @errordeveloper thanks for the help. I got MQTT working on the Yun sans Temboo. Do any of you know if MQTT subscriptions expire? everything seems to work fine but after a few hours of inactivity the Yun does not appear to receive messages from Xively anymore. It is hard to tell at this point if the Arduino is frozen or the subscription/communication is broken.

errordeveloper commented 11 years ago

That sounds like a memory leak to me.