I’ve written before about my Math and Computational Methods for Physicist course and how we’re doing a cool Arduino-based Internet of Things project. I’ve been brainstorming some new things we might do with that project and I wanted to see if you, dear reader, might have some suggestions/observations/complaints/whatever.
First an update on the database and our prototype. I haven’t added much to the database. Really only a dashboard list for the admin (me) showing the total number of measurements for each machine and when the last measurement was. It turns out that even though I fixed the pretty common wifi freeze with the watchdog approach, it still goes down about twice a week. I’m not really sure what’s up with that. The most recent time it happened I didn’t notice for about a day so when I went to look at it I noticed it was pretty hot. Unplugging it for 10 seconds or so and then replugging it seems to have fixed it for now. Any thoughts on how I can figure out what causes those very intermittent problems would be greatly appreciated. The class has devoted one lab to Arduinos so far and they all got to the point where they were measuring and calibrating temperature and controlling an LED. Pretty good for 90 minutes. We meet again about it this coming week when I’m hoping they’ve all found a “client” that they can program the arduino for.
Using a clock
The first new idea is to deal with client requests that are time-based. Something like “every night at midnight check the XXXX and report” as opposed to what we already have: “every Y minutes do something.” The arduino has a millisecond timer on it, but you can’t trust it to know in absolute terms what time it is. So at first I thought we couldn’t handle those requests. But then I remembered that we have a working wifi card on all of these! I figure we can just have it check the absolute time on some time server somewhere and at most be off by Y minutes. That’ll likely satisfy those sorts of clients (at least I hope so).
Already a few potential clients have asked for things like “every time the door opens measure XXX and report.” If they can handle a resolution of Y minutes, then we’re all set. Otherwise we’ll have to use the built-in interrupt stuff for arduinos. Then if the door opens an interrupt will be thrown and we’ll execute the whole “measure XXX and hook up to the internet” code.
Make a measurement if we say so
This is the one that I would really like some advice on. Some students and I were brainstorming how we might communicate to the arduino to make a measurement. Really this would be an extension of the “using a clock” idea above. We’re thinking of updating the database web site so that the owner of the machine (which is currently defined as the person who most recently updated the code for that machine) could update a page with something like “yes” or “no” returned so that the machine would check that page first (every Y minutes, say) before deciding whether to do anything else. We could, of course, get more complicated with various messages triggering lots of different responses from the machine. The limit would be the storage on the arduino (20 totally different codes stored might not be possible, for example) but I think we can still do some cool stuff.
I guess my question is: is this the right way to go about it? I read a lot about making the arduino basically a web page server so that you can go to it and ask for things. That’s the bulk of the pages you get if you search for “arduino internet of things” so I know it’s pretty popular. My problem is that it seems like it’s asking the arduino to do quite a lot, and essentially be fully on (as opposed to a boring “pause” loop) all the time. I figure this approach saves a lot of that, but maybe I’m missing something.
So, we’d love your help. If you have any ideas/hare-brained-schemes/concerns/anecdotes/love-letters-to-mathematica let us know in the comments below. Here are some starters for you:
- I’m in this class and I’m really excited about this project. What Andy forgot to add was . . .
- I’m in this class and I hate it. What I’d love is if someone made it clear to Andy that this is a dumb project so we don’t have to do it.
- I’m in the HUWebApps group that Andy talked about here and I think this could be some fun work for us. One thought I had was . . .
- I think these new ideas are really cool. One thing I’d be a little worried about is . . .
- I think that some of these ideas are really bad, damage-people-for-life bad! Here’s a better way to go about it . . .
- I’ve done some similar work <snark>thanks for linking to me</snark> and I’d suggest you read this, this, and this.
- I run my arduino as a web server and it works great! You should really switch because . . .
- I run my arduino as a web server and it sucks! I’m thinking of switching to how you do it, can I use your database?