Temperature Data Logger

This is our second project with Michael Margolis, this time a two sensor temperature data logger. In our case we have set it up to measure internal and external temperatures but you might equally use it to measure flow and return temperatures on a solar thermal system or something else. You could also expand the number of sensors to 5 and start looking at hot water tank stratification in your solar system.... the possibilities are many and the cost is very low. We are using the MCP9700A temperature sensor in this example as they are very cheap and much less noisy than the LM35, especially on long wires. As they are such good value we have made up a little kit which we are providing at the same cost as a bare Seeeduino Stalker.... to get you off to a good start - enjoy.

The Seeeduino Stalker sketch is nicely written by Micahel Margolis and takes care of some of the pitfalls experienced with the Stalker demo code. The sketch will either create a new file on the card if it doesn't exist and start writing to it or it will append an existing file - gone are the frustrations of non-zero byte files and formatting sensitivities - it just works much better.

Michael has also included a write error LED which lets you know if you have a problem writing to the microSD card without having to pop the card out and have a look. You may notice that the sketch is also sampling 8 times during the sample interval and averaging the result to iron out aberations.

The sketch is available below - enjoy, and please let us know how you get on via the comments section at the bottom of the page.

The Parts List:

2no. MicroChip - MCP9700A - temperature sensors.

1 no. LED.

1 no. 100Ω resistors for the LED

The wiring is simple enough:

The Sensors:

The MCP9700A temperature sensor looks like this (Actually ths is an LM35 which we were using intially - the MCP9700A is wired the same)

Sensor Left Pin (+V) to Stalker +5V

Sensor Mid Pin (Vout) to Stalker Analog pin 0 & 1

Sensor Right Pin (GND) to Stalker GND

The LED:

Solder a 100Ω resistor to the positive (longer) leg of the LED.

This Write Error LED is on Stalker digital pin 6 so the LED positve (with the resistor attached) goes to Stalker digital pin 6 and the negative leg (adjacent to the flat on the plastic LED housing) goes to Stalker GND.

You should end up with this (with the MCP9700A flat face towards you):

Mounting the sensors:

Your call really, there are some nice mounting ideas out there on the web. For this internal/external temperature example I had the internal MCP9700A bare and the external sensor mounted in an old 35mm film canister using SUGRU silcon stuff to seal the hole/lid - a wrap of tin foil helped reflect any incident light (I am working on a propoer external sensor housing at mo - more later).

The Arduino Sketch:

You need to download the FAT16 Arduino library from http://code.google.com/p/fat16lib/ and place the files in your ...\arduino-0019\libraries (or similar if using a different Arduino IDE version) folder before you attempt to upload your sketch (downloaded from the bottom of the page).

You can adjust the logging interval using this line in the code:

const long logInterval = 300;

The 300 is the interval, in seconds, at which the data gets written to the SD card. In this case every 5 minutes. A microSD card of 256Mb is enough space to store about 8 million time stamped data records which at a 5 minute logging interval equates to about 76 years worth of data - should be enough !

You should now be set - I have assumed you have successfully uploaded the sketch below to your Stalker data logger and inserted your SD card ready to power up for your data logging session.

So, all being well, the Stalker onboard LED will be blinking every time a sample is taken and gets written to the microSD card. Once you have collected your desired data period you can download your CSV file from the microSD card which will be in the following format:

Pretty good - but even better if you graph it out in your spreadsheet:

This graph shows internal and external temperatures in centigrade recorded over a 4 day period. Have fun & do share your experiences via the comments section at the bottom of the page.

The Sketch:

You can also download the PDE directly from the link at the bottom of the page.