Wednesday, September 4, 2013

Raspberry Pi and Xively Part 1

Frankly, I've been disappointed in Xively since it changed from the old Cosm.  Remember, before that it was Pachube.  Once upon a time it was a group of ambitious programmers that were working on a dream, now it's something else; I'm not sure what.  However, I haven't given up on them.  They still haven't completed things like their graphing API that everyone wants to use, but they have expanded their default graphs so I can select the period I want to see.  So, maybe there's still some interest among their developers.  However, I did ask them to come up with a way to port the legacy feeds to their new development system, and they put me in contact with a developer that was supposed to work on it.  This was over a month ago and I haven't heard from him again in weeks.  The single most annoying thing was their removal of the forum they had.  Now, if you have a question you're supposed to go to StackOverflow, and those folks can be rude and condescending.  Sure, I'm not the sharpest tool in the shed, but there are people on there that are just plain jerks.  I absolutely hate asking questions there.

Anyway, I started playing with Python and their site.  Since I might as well try their new interface and various capabilities at the same time, I followed their example and used their library.  The first thing I ran into is that their python library is considered preview so I had to use the '--pre' option to load the darn thing.  Next, they want me to use a virtual environment to develop, since I don't want to learn anything unnecessary at this point, I just ignored that part.  Using the example shown at http://gnublade.github.io/xively-python/tutorials/raspberrypi.html, I put together a module and tried it.  It worked.

However, do not under any circumstances name your source module the same as the library you're trying out.  I named my source module 'xively.py' and it took me a couple of hours to figure out what the heck the problem was.  When I changed it to 'testxively.py', I could take out the hundred or so debug statements that I had scattered all over the place and get on with trying it out.

Right now, I'm trying to combine gathering some data from my XBee network and incorporate it with the Xively example to create a module that can update Xively with real data.  In my pursuit, I had to learn about logging with Python; seems the scheduler module uses system logging if it encounters an error.  The Xively example only updates one data item, so that means I have to learn how to update a whole series of them (ain't no example for that).

So, maybe you understand why I labeled this entry as 'Part 1', I'm not sure how many parts there will be, but this is getting really confusing.

Part 2 of this is here <link>

12 comments:

  1. Hi. Thank you very much for sharing.
    I have a DHT22 Temp/Hum sensor working with Xively.
    If I’m in my home network everything shows in real time (graphics and Values).
    If I’m outside my home network the graphics are in real time but I need to refresh the page to get the updated values.
    Is this happening to you?
    Thanks for your help.

    ReplyDelete
  2. Yes, I've had that happen. I overcame it by using jquery() to update the attributes of the thing I'm displaying. It's a strange and complicated procedure just to change a value on the screen, but I got used to it. Is your page visible on the internet? I can take a quick look if you point me at it.

    I may not come up with anything, but it won't hurt anything to look.

    ReplyDelete
  3. Thanks for your quick reply Dave.
    This is the site:
    https://xively.com/feeds/809964576
    Ignore the load_avg, it's just for tests.
    If you need more info please let me know. Thanks

    ReplyDelete
  4. It worked fine for me. What I saw though was that the text showed a different value from the last value received. The last value received might be 3, but the text was 7. Eventually the text would change and something else would appear there. I think the chart or the text is out of sync, possibly because of averaging or rounding or something.

    I went and took a look at mine and it was doing the same thing. Watch it a bit and you'll see what I mean. I don't have a clue what the difference is between inside your house and outside though.

    ReplyDelete
  5. Ok, maybe I didn't explained myself well...
    Inside my Pi network the values were updating from 10 in 10 seconds.
    But when I tried outside (ex: from my mobile) I had to refresh the page because the graphics were updating but the numbers not.
    I've found why but I don't know the problem...
    That was happening because when I was at home I was logged at xively.com and when I was out I was not logged!!!
    Do I have to be logged in to see the values updating in real time?
    Is this happening because I didn’t execute the DEPLOY step?

    ReplyDelete
  6. OK, I'm a bit lost. Is there some code or something that I can see that will help me understand what you're doing?

    ReplyDelete
  7. Ok. I've created a new blog to show the code:
    http://greenpihouse.wordpress.com/

    ReplyDelete
  8. Sorry, forgot that. It's ok now.
    Thank you

    ReplyDelete
    Replies
    1. I looked at the code long and hard and can't find a thing wrong with it. To me, it looks like you're doing everything right.

      So, I went to my feed and watched it for a while. Then I logged out and hunted it down as a public feed on their site and I saw exactly what you saw. The graph updates on a regular basis, and the text up in the right hand corner never changes. It went to over 4 minutes without an update showing, while the graph worked just fine. I could put my cursor on the graph and read the latest data.

      So, it looks to me like the entire problem is on xively. You have to be logged into the site to see the latest data. Even then, there may be problems, like I noted before, the text and the graph don't agree even then.

      That's just another complaint I have about them. Too bad they aren't pachube any more.

      If you get disgusted with them, take a look at GroveStreams. I have the code I use to update them on this blog, and so far, they're working pretty good for me. I may be moving my stuff over to them soon.

      Delete
  9. Thank you!! I'm so happy right now.
    Not happy with Xively of course...
    Yes, I will take a look at your suggestion, GroveStreams.
    I will also try ThingSpeak. They have a lot of good feedback.
    Thank you very much for your time and effort solving my problem.

    ReplyDelete
    Replies
    1. ThingSpeak is a nice operation. I have my code for them on this blog also. The only problem I notice with them is that they go offline sometimes for varying lengths of time. It shows up as a 'bad gateway' error in my logs. They work plenty good enough for almost everything folks like us do.

      My thinking is that I want to have a company that is building up because they are paying a LOT of attention to how things work.

      You have fun now.

      Delete