Not sure if I am having problems with device code or agent code

I am trying to read multiple channels, one channel displays temperature, the other displays current. I think I have the device code running properly. Not sure with the agent code. When I had my code running just reading temperature I was getting put and get messages on my Xively connection. When I modified my device code to read current on the second channel Xively displays both channels (temperature and current values) only when I build and test my device code and my Xively connection only displays put messages no get messages. Does any one have any ideas why I do not continuously update the channel values?

I had some troubles at start, it could be u logging to fast.
To check press the get/post message on xilvely (see image), if its to fast it
will be noted there.
If your over the speedlimit @ xilvely it will just disregard and won’t post new values.

If u want to know how fast the max speed is, maybe u should ask the professors here :slight_smile: the script iam using was from the bearded professor (inventor).

What do you mean by your Xively connection only displays put messages and no get messages? Do you mean the Xively Console (what @pather took a screenshot of), or do you mean your logs, etc?

A lot of people are using the Xively code, so it’s likely something in your implementation - if you can share some code, logs, etc it would be a lot easier to debug :slight_smile:

Here is the code that I am running

A couple things…

You’re using very old Twitter code - here’s a link to the new Twitter class that will remove a lot of ugly hashing code :slight_smile:

It doesn’t look like you’re making any GET requests to Xively in your code, so it’s not surprising that you’re only seeing PUT requests in the Xively console.

Does that explain why my Xively console does not update with new readings. Also I think I attached the wrong agent code. Here is the latest

I am not using the twitter code and removed it. I attached the latest agent code to my discussion dated 8/6. Still not having success in getting values to update on the Xively console. Any suggestions?

Your code looks OK - assuming all of your Feed, Key and Channel information is working.

What response are you getting from the PUT?

Change:
`device.on(“Xively”, function(v) {

channel1 <- Xively.Channel("Platten_Current");
channel1.Set(v.Current);
Val1 = v.Current;

channel2 <- Xively.Channel("Platten_Temperature");
channel2.Set(v.Temperature);
Val2 = v.Temperature;

feed <- Xively.Feed(Feed_ID, [channel1,channel2]);
client.Put(feed);

});`

To:
`device.on(“Xively”, function(v) {

channel1 <- Xively.Channel("Platten_Current");
channel1.Set(v.Current);
Val1 = v.Current;

channel2 <- Xively.Channel("Platten_Temperature");
channel2.Set(v.Temperature);
Val2 = v.Temperature;

feed <- Xively.Feed(Feed_ID, [channel1,channel2]);
local resp = client.Put(feed);
server.log(resp.statuscode + " - " + resp.body);

});
`

Tried your suggestion
My Xively console is displaying 200 put feed. The channel values being displayed correctly. The problem is that the channels are not being updated. The channel values get updated only when I build and run my agent code.

What is the imp log displaying though?

2014-08-12 08:03:55 UTC-5 [Agent] { “id”: “Platten_Current”, “current_value”: 6.38 }
2014-08-12 08:03:55 UTC-5 [Agent] { “id”: “Platten_Temperature”, “current_value”: 69.8 }
2014-08-12 08:03:55 UTC-5 [Agent] 200 -

The above occurs only when I build and run my code it agent code does not update

Thank you very much for setting me straight on imp.wakeup. I changed my code as you suggested. Life is good!

Thanks again for your help.

So it looks like this is an issue with your device code. You have a few weird things going on, and I suggest you take some time to read article, which explains imp.wakeup, why while(1) loops are bad, and some other details that are fairly specific to the imp: https://electricimp.com/docs/resources/wakeupguide/

The main problem is around your while(1) loop - infinite loops lock the thread of execution, meaning that other background tasks can’t complete (like important networking things).

Additionally, your while(1) loop doesn’t have a timeout, meaning it’s going to execute as quickly as it can on the imp.

Along with this, the while(1) loop calls GetCurrent_A and reachChip189 - both of which reschedules itself to run with imp.wakeup.

This means that each time the while(1) executes, it will create another instance of those functions that are rescheduling themselves.

You probably want to pull the imp.wakeup lines out of those two functions, and replace the while(1) loop with a function that calls itself using imp.wakeup.