Monday, June 2, 2008

Things That Don't Work vs Things That Do

I've never been completely happy with my temperature logger. It's a bit fragile in the sense that if anything at all goes wrong, and there's no way to tell that at the time, I lose the entire run. I lost a run Memorial Day weekend.

Instead of storing the measurements on the Arduino, I'd like to instantly beam them onto my computer far inside the safety of the house. That way I can track things realtime as well as be assured that I have them. Coincidentally, for my birthday, I got both another Arduino1 and Making Things Talk.

The book describes a great number of schemes to make microcontrollers talk to each other and to computers. You can use wireless networking, bluetooth, XBee, etc (I have only the vaguest notion what some of these are). Naturally the easiest protocols require the most expensive hardware. I only need one way, slow communication, so I got a simple RF module.

Claim:

It works just like a serial port! Just connect the transmitter to the TX pin and the receiver to the RX pin! It Just Works(tm)!

Reality:

No.

Perhaps my unit was faulty. I found many tutorials and guides across the internets and while results varies, I can't ever really say it worked. I did see data appear for a short time, but mainly what I saw was noise. Or nothing at all, which is even less explicable.

Last night I had a brainwave. Or brainstorm. Something happened to my brain and it resulted in an idea. Why not use a wireless laptop as the go between? The kids have these OLPC dealies. The laptop has a USB port and does WiFi. I have a WiFi router (specifically purchased, used, to work with these laptops). About 30 minutes and 10 lines of Python later, I was reading values from /dev/ttyUSB0 and sending them out over a socket to my desktop to another 15 minutes and 20 lines of Python.

The guts of the entire scheme are already there. But with so much success so fast, I'd like to add features. For instance, instant graphing of values on both ends. A protocol so that the laptop knows if there's been an error and can tell me, out in the field. When I have more than one sensor, I'll need a way to indicate which sensor had what value. It'll be like a complete Science Sensing Station!

1If you are at all interested in robots, sensors, controlling stuff with computers, electronics or just plain messing around, I highly recommend the Arduino. That SparkFun item is all you need, assuming you have a USB port (and possibly a cable). Well....you may also need some external electronics, depending on what you want to do. LEDs, resistors, motors, etc.

3 comments:

  1. Update: In another hour or so last night, I made this pretty reliable. The server portion starts a new data file every time the client reconnects, so no data can be lost by hiccups and I can turn it off and on at will.

    I was able to measure data in the kitchen (with Dinah) and have it show up on my desktop in the computer room. So....awesome!

    It would be really cool to have it graph in realtime too, but I've never found an easy to use graphing library for Python. Or any language, really. Why is graphing such a hard thing to do?

    ReplyDelete
  2. how about using www.pachube.com to log and graph your data? lots of examples using arduino, and looks like there's even a olpc feed

    ReplyDelete
  3. Never heard of pachube, but it looks like it could be pretty cool. You need an invitation code to even explore, so we'll see if they give me one. Thanks for the tip.

    ReplyDelete