As part of a “grand plan”, I’m thinking about how to implement a feature rich Arduino web application, without getting myself tied up in knots worrying about blowing the capabilities of the ATmega in terms of program size, memory size or processor speed. Without an SD card to store all the files on, the simple logical answer is to hand off as much work as possible to “someone else”, so the content (i.e. all the big files) lives on my static host and the grunt of the runtime execution is performed by the user’s browser. The only thing the Arduino needs to do is serve the initial landing page and respond to (tiny) data requests. I know I’m not the first to approach the problem from this angle, but a bit of Googling hasn’t turned up any concrete examples upon which I could base my efforts.
- Arduino returns a home page that;
- references jquery.js from a CDN
- references webapp.js from my static host
- references webapp.css from my static host
- doesn’t really contain anything else other than a bare HTML structure
- generates UI content
- makes AJAX request(s) to RESTful web services on the Arduino
- references any images, or other required content, from my static host
Serving the webapp.js and webapp.css from my own static host means that;
- code changes to the webapp can be deployed instantly with no need to change anything on the Arduino or upload a new sketch
- the Arduino does not have to concern itself with storing/returning the large code files associated with the JavaScript for the webapp
- because the HTML page is served from the same domain as the JSON responses, same-origin policy is satisfied for AJAX, without having to mess about with JSONP or proxies
- if I keep the JSON structures simple, there’s no need to go hunting for a library implementation as it’s just a bit of string concatenation here and there
When that elusive hour of “spare time” turns up, I’ll document the process and throw the code up on GitHub, but for the moment you’ll just have to say “wooh” and use your imagination!
Have you thought about using COSM (Pachube) as a data hub? You can send them CSV, JSON or XML (EEML) on your own schedule. They will even pickup the data every 15 minutes.
Data aggregation sites like Cosm are good for display of historical data provided that you’re happy to view the data in whatever way they provide for you to do so. If that’s enough for one’s needs then it’s great (particularly as the accounts are now free) but if you want to display your data in a different way, or do more with it you’ll run up against the limitations pretty quickly. Yes, they’re extending their API – but I always seem to want to implement something that’s not on somebody else’s to-do list.
If you’re not just dealing with graphing historical data and also want to interact with the Arduino environment in real time, you need an alternate solution. Imagine a scenario wherein you click a button in the UI and maybe a relay gets switched on, or a message is sent to another wireless device to tell it to do something. The beauty of having that UI under you control and inside a browser is that (when written properly) it really does work anywhere – be that the browser on a PC at home, one at work, the one in my phone or the one in my TV.
Like I say, it’s a “grand plan” 😉 If I never find the time to do half of this stuff in my head it’ll just remain a pipe dream.
I think you a casting cosm in a role they do not occupy (at least for now). They are a data broker not an aggregator giving you access to data that people are willing to share (nearly everyone) and of course your own data.With a large number of servers there performance is spot on.
If you want to control you arduino, look at http://open.sen.se . This is a startup wanting to do exactly what you are proposing. They are running as a closed beta for now. It is very early days and still pretty rough but they are getting there. I haven’t linked to an arduino but it looks straight forward. (They supply a sketch to do it.) They will also access your data from pachube. If you want an invite, I’ll be happy to send you one.
So I guess I’m saying that while control is good and doing it yourself delivers a perfect solution, using what’s available gets you there and doesn’t need to remain a pipe dream.
I’m a software developer by day and probably a little too often am guilty of implementing my own wheel purely for the hell of it. Sometimes it’s because all the other wheels have some flaw or another, but sometimes it’s more so I know what’s going on so I can fix it if it breaks. Too much time spent with poorly designed and documented APIs from software houses that should know better, I guess.
The Open Sense stuff does indeed look interesting; just working my way through their blog at the moment and I keep catching myself nodding and muttering positive things. I’ll take you up on that invitation, thanks.
I’ve complete my senseboard implementation at http://open.sen.se/SeekingGreeness. Write up at my blog