Temperature Data Logger
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. The sketch relies on the SENSIRION library by Markus Schatzl & Carl Jackson with a little tweak by Arduino Forum member tasasaki to polish it off nicely - thank you all for your work on this. The sketch & library are 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:
- 1 no. Seeeduino Stalker 168 (Battery for the on-board Real Time Clock not included)
- 1 no. Breakout board for the SHT1x or SHT2x sensor
- 1 no. SHT11 - I2C Temperature & Relative Humidity sensor
- 2 no. SMD 10K resistors
- 1 no. SMD 0.1uF capacitor
- 1 no. LED to show card write errors
- 1 no. 100Ω resistors for the LED
- 1 no. 256Mb microSD card
The wiring is simple enough:
Once you have soldered up the breakout board you have 4 connections to make to the Stalker board - the breakout board looks like this before & after soldering.
Once you are all soldered up connect the breakout up as shown:
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 positive (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.
Mounting the sensors:
I need to work out a nice mounting for this sensor but just just remember that the relative humidity is sensed via capacitance and should be 'IN' the air you are measuring.
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 300is 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 temperature in centigrade, relative humidity and dew point recorded over a 2 day period in our bathroom. You can clearly see the heating cycle and the two shower spikes, less obvious is the bath taken the evening before the two showers. Have fun & do share your experiences via the comments section at the bottom of the page.
You can also download the PDE directly from the link at the bottom of the page along with the Sensirion library.
* SimpleSHT11Logger -
* This version logs the temperature every 5 minutes
* change logInterval variable to change interval
* Copyright Michael Margolis 2010
* In association with www.airsensor.co.uk
#include <Fat16.h> // the SD Card library - http://code.google.com/p/fat16lib/
#include <DS1307RTC.h> // a basic DS1307 library - http://www.arduino.cc/playground/Code/Time
#include "Sensirion.h" // a nice library from - http://www.arduino.cc/playground/Code/Sensirion
const uint8_t dataPin = 2;
const uint8_t clockPin = 3;
Sensirion tempSensor = Sensirion(dataPin, clockPin);
const int fileLedPin = 6; // LED to indicate a file error
const long logInterval = 60; // the interval in seconds between each log
const char *fileName = "logdata.csv"; // the name of the log file
setSyncProvider(RTC.get); // the function to get the time from the RTC
// initialize the SD card
// initialize a FAT16 volume
// open file for append, create if it doesn't exist
if (!LogFile.open(fileName, O_CREAT | O_APPEND | O_WRITE))
// clear write error
LogFile.writeError = false;
tempSensor.measure(&temperature, &humidity, &dewpoint);
time_t timeStamp = now();
// write the data to the card at the end of every line
delay(logInterval * 1000L);
// routine handle file errors
void error(int err)
// blink forever
delay(err * 200);
void printDateTime(time_t t)
printDigits(second(t),',' ); // uncomment this to print seconds (and replace the comma above with colon)
// print a space here if you need it
// LogFile.print(year(t)); // prints year using 4 digits
LogFile.print(year(t)-2000); // prints year using 2 digits
void printDigits(int digits, char seperator)
// utility function time with leading 0
if(digits < 10)