Taking (and keeping) your temperature!

I swear I don’t have a penchant for medical terminology but this ioBridge stuff is making me feel like that time I stayed at a Holiday Inn… so refreshing, I think I could perform surgery!

After my heart hacks (see my previous posts) I had questions from some friends about how we could graph the data from an ioWidget’s (my term). Initially, I wanted to push the data into a Google Spreadsheet but unfortunately there doesn’t seem to be a higher level javascript library supporting Google Docs and sorting through the feed URL’s was just too complicated.

At the same time I was thinking through this request, I received a resounding response from the ioBridge team! Although I’d worked around the need for a simple API they quickly responded to the desire (apparently I wasn’t the only one with interesting ideas) and now there’s a full JSON API!

I won’t bore you with my initial graphing solution as the sample made it into their official API demo (along with some much needed code enhancements). However, there were a few pitfalls with that approach that I still didn’t like, most specifically that the data is “lost” every time you reload the page.

It took me until after the holiday break (along with a welcome return to python) but I’ve solved my initial frustration with great results.

Here’s a script which will poll my ioBridge module and then store the results of my tempreature sensor in a Google Spreadsheet that I created! Once the data’s there you can use Google’s visualization widgets to make some fun graphs!

Aside from some setup and “ease of use” code, the real work is done by two very brief classes. I deliberately didn’t add some error checking nor make the widget class generic (it’s actually proxying the full ioBridge module) so I think it should be straightforward enough to modify for your own uses!

All you need to do is create a spreadsheet and open it in your browser. Copy the key from that URL and paste it, along with your ioBridge feed URL, into the appropriate places in the script (the locations are commented).

I simply run this from a cron script every few minutes (once I get more data I’ll reduce the time) and although there’s not a lot of variation in the data (I deliberately introduced some to make the graph more interesting) it’s a spectacular way to record, visualization and act on the sensor’s findings!

Good luck with your own modifications and let me know if I can help!

About jay

I'm trying to build something interactive where I can learn from others and hopefully share useful knowledge too. thecapacity@gmail.com
This entry was posted in code, Google, hardware, iobridge, python, visualization. Bookmark the permalink.

10 Responses to Taking (and keeping) your temperature!

  1. LenQpublic says:

    Thanks for posting this – SUPER useful – great job!

    • jay says:

      Thanks LenQpublic,

      I’m very glad it was useful and also glad that you figured out (and shared) the “p_###” vs “r_###” issues.

      I’m not sure why the keys would be different but maybe the identifier has more variety then I’d assumed (i.e. the p and r might stand for something, go figure google!).

      I’ve been really busy starting a new job right now so I might be slow on replies [no internet at work … 🙁 ] but if you need help or ideas let me know!

  2. LenQpublic says:

    I received the same error as greg. But I noticed that my Spreadsheet Key had a different format.

    In the code:


    So I put in the correct r_ key.

    I also changed the name of the Sheet to “data”

    It worked after these two changes.

  3. greg says:

    I got it working. The spreadsheet I made was giving me troubles, so I made a copy of Jay’s spreadsheet and saved it in my own docs and used that new key and everything works wonderfully. Hope that helps some others who may have troubles.

  4. greg says:

    I can’t get this to work. I made a spreadsheet with Date and Temp columns, I copied the key and my feed url and I get this error
    ‘reason’: server_response.reason, ‘body’: result_body}
    gdata.service.RequestError: {‘status’: 404, ‘body’: ‘\n\nNot
    Found\n\n\nNot Found\nError 404\n\n\n’, ‘reason’: ‘Not Found’}

    It seems so simple but I can’t figure it out. Thanks for the great work.

  5. Pingback: thecapacity : Wiimote Controlled Coil Gun

  6. Pingback: Writing Data to a Spreadsheet

  7. Chris says:

    Great idea! I’ve been trying to figure this out as well – I’ve tried your sample code and have it working…. Thanks again!

Comments are closed.