Archive for July, 2012

Data logging shield: update

July 24, 2012

I ran my fridge data logger a bit longer, with the following results; not too different from the previous results.

I’ve posted the code and data at github, including the R code to make the above plot.

I ran the data logger for a couple of days, but it seemed that the battery went mostly dead after just one: the date and time started getting reset as 165/165/165 165:165:85 and then it seemed that the arduino went off and on, so that it would start writing to a new file. I clipped off all the messy bits to make the figure above.

Here is the clipped file, and here is the longer file with some of the messy bits.

Advertisements

Data logging shield

July 11, 2012

I bought the data logging shield from adafruit, as well as the 6 x AA battery holder, so I could try out their refrigerator logger: logging the light and temperature of my fridge, to see how the temperature fluctuates and how much the temperature rises when the door opens.

First, I needed to do some soldering. I hadn’t soldered in a while, so I first put the jack on the battery pack. I’ve done a bunch of these, and Lady Ada has a clear tutorial, but I botched this rather badly.

  • When you do the black wire, on the outer tab, you need to put the solder on the inside rather than the outside. I got too much on the outside and wasn’t able to screw on the plug cover.
  • Cut it off and put on a different one, but realized afterwards that I’d used a 2.5 mm plug instead of a 2.1 mm plug. The larger plug fits into the arduino, but it’s a bit loose and so the connection is unreliable.
  • Cut it off and tried again, but forgot to put the plug cover on the wires first.
  • Cut if off and tried again, and finally got it. The wires are a bit short, but the battery pack works.

I moved on to soldering together the data logging shield. Lady Ada’s instructions are, as always, superb and easy to follow. It all went together easily.

It wasn’t too clear what the LEDs were for, but when I got to the instructions about the light/temp logging, it became clear. You use jumpers to connect them to digital pins 2 and 3 (green will be 3 and red will be 2): note the two short yellow wires in the top right of this picture. Then you do whatever you want with them. (In the light/temp logging sketch, they use green to indicate that a reading is being taken and red to indicate either an error or that data is being written to the SD card; see the walk-through of the code.)

There was one other thing that wasn’t clear: the shield came with a 6-pin ICSP header, but it isn’t mentioned in the assembly instructions, though it does appear in the picture of the shield, next to the two jumpers for the LEDs. I soldered it there but I’m not sure what it would be used for. (As mentioned at the adafruit forum, it’s for programming the arduino via ICSP rather than USB; I don’t think I’ll be doing that.)

Lady Ada used the prototype section of the data logging shield to permanently solder the sensors. I instead put extra long headers in the shield, so that I could easily plug in jumper cables and attach sensors via a breadboard. I also put a single pin of extra long header in the 3V spot on the shield.

Here’s the assembled stuff:

It was super easy to follow the code; I had no trouble getting it all to work.

Here’s the shield in the refrigerator:

I’d planned to leave it in for 24 hours, but I pulled it out after 16 hours so that I could make a plot of the results.

Here’s a plot I made (in R) of the temperature over time. The dots at the bottom indicate when the door was opened; red dots indicate the door was open for more than 10 seconds.

The temperature is mostly below 40 degrees, as it’s supposed to be. I was surprised to see it dip so far below freezing. Just before noon, I left one side of the refrigerator door slightly ajar (a not uncommon mistake in our house). I went into work last night and stayed absurdly late; I opened the fridge when I got home, at a bit after 2am.

I’ll add R code and a sketch of the circuit later. I ended up using the light/temp logging sketch from adafruit without changes, so there’s no need to include that.

Given our tendency to leave the refrigerator door ajar, maybe I should create a temperature-based alarm. No; I think the batteries would cost too much.

Ethernet shield

July 8, 2012

After a long delay, I’m back to playing with electronics.

I bought an arduino ethernet shield from dfrobot (cheap, because it’s the old version that doesn’t have an SD card slot). I got it to work fine with the arduino Ethernet library. The only tricky bit was the MAC address: I tried using a random one, and the arduino would hang at Ethernet.begin(mac). But for some reason if I switched the initial hex digits to 00, then it worked. I ended up just adding 01 to the MAC address for my laptop.

After trying out the very simple examples that come with the arduino Ethernet library, I hooked up a temperature sensor to it, got an account at cosm.com, and used the CosmClient example to log temperature data for my living room for a day. It was a bit too easy, so I don’t feel particularly accomplished. And the precision of the TMP36 temperature sensor I used (from the Sensor Pack 900 from adafruit) is rather crappy. It’s attached to an analog input and gives temperature in 1° increments.

I’m not sure what I’m going to do with the ethernet shield, but it seems like it’d be cool to be able to turn lights on and off via the web.

I ordered the data logging shield from adafruit, because I wanted to log the temperature inside my refrigerator, as Lady Ada had done. (I guess I should have just ordered the proper ethernet shield, which would have included ethernet and SD card access!)

The code for my little temperature logging project is on github.