// how many milliseconds between grabbing data and logging it. 1000 ms is once a second#define LOG_INTERVAL 1000 // mills between entries (reduce to take more/faster data)

// how many milliseconds before writing the logged data permanently to disk// set it to the LOG_INTERVAL to write each time (safest)// set it to 10*LOG_INTERVAL to write all data every 10 datareads, you could lose up to // the last 10 reads if power is lost but it uses less power and is much faster!#define SYNC_INTERVAL 1000 // mills between calls to flush() - to write data to the carduint32_t syncTime = 0; // time of last sync()

// Now we write data to disk! Don't sync too often - requires 2048 bytes of I/O to SD card // which uses a bunch of power and takes time if ((millis() - syncTime) < SYNC_INTERVAL) return; syncTime = millis();

// blink LED to show we are syncing data to the card & updating FAT! digitalWrite(redLEDpin, HIGH); logfile.flush(); digitalWrite(redLEDpin, LOW);

}[/color]

I tried a few things like combining the void setup and replacing the two void loop by naming them void loop_code 1(); and void loop_code2();this was not working for me and many errors appeared!

by the way: the code for the light sensor and temperature does not have tobe in there, I want to have a blank shield where I can just put my analogue inputs into it.

My goal is to use this datalogger for monitoring many K-type thermocouples using the AD595 thermocouple chip!

In my experience, as a hack programmer, the only way to really combine two pieces of code like that is to completely understand how each piece works. Once you fully understand what's happening it will start to become apparent which pieces you can keep and what you need to rewrite. It isn't so much about bashing two sketches together as combining two concepts. Just read them over and over and make experimental changes until they make sense. You don't need some of the code on the logger so work on eliminating that as a means to understanding how logging works.

One little tip. I notice that the logging sketch uses delay() for timing when to log. That won't be acceptable when you combine the two. So now there's another sketch that you will need to digest - blink without delay. The concept behind it will be needed.

I'm a beginner in arduino but know my electronics! Coding is not my best part but eager to learn from anyone!

I am wondering if what you are attempting to do is initially to complex for you, considering you are new to Arduino and maybe programming in general.My question to you is, have you played around, experimented with the examples?Doing so will give you the best possible understanding in a shorter time, learning from experience and experimenting.

It seems you have tried by combining the two setup sections and doing some other things.You really will need to understand each program in its own right and then be able to pull them apart to re-combine into one program.I personally would not write the programs like you have presented, I find it difficult to read, especially with the comments left justified and on separate lines.I make use of functions to break the code down into relevant parts, I also break larger code sections into separate source/header files.Doing this make it far easier to read and develop larger code.

I do not want to dampen your enthusiasm, but I am thinking and concerned that you may well be overwhelmed by trying and ending up disheartened with failure.I have code that will do what you want that I have developed, but I can tell you it does take time to develop, time to sit down and learn.For me or others giving you code, I would guess you will not learn so much, what do you think?Can I encourage you to try merging the code of two smaller projects initially.I would be keen to hear of your progress.

One last question, check that your Adafruit data logger has a hardware based rtc on board, as your code needs this?

Thanks a million for your post! it"s been a wile since working on my Arduino Thermocouple project because of busy with work but I'm back again:)I"m still eager to learn to write my own code and therefore have bought a Cooking book from arduino with many example codes in there with explanatory text (very handy). The code of "monstermux" I have learend to understand how it works and the same for the Datalogger however the datalogger code is a bit more complex and don't undrstand all of it yet.There are indeed a few elements in there that can be left out.Just to have the compleet picture I have printed out everything and manualy "cut and past" what I think I need in the right order.Still no succes though but I have the feeling I get somewere, it needs more studying and understanding how to combine code.I will sure let you know when I'm done and have it up and running! (hopefully..)

Well, this is what I have done so far: the code is combined and compiled without errors but doesn't mean it's a good one (not tested on the hardware yet) I have my doubts over the Delay entries as mentioned by jimmy60 and wondering if I need to use another type of Delay() to overcome this problem I thought of using the myDelay function but like to know from someone if it's a good option or not? well here it is:

/* MonsterMux32 Demo Code Critical Velocity 2009 This code selects an analog channel and prints the value to the serial port. For more information, visit www.criticalvelocity.com/mmux32*/

int sensorValue;char muxch = 23; // change this to the channel number you wish to read.

#include <SD.h>#include <Wire.h>#include "RTClib.h"

// A simple data logger for the Arduino analog pins

// how many milliseconds between grabbing data and logging it. 1000 ms is once a second#define LOG_INTERVAL 1000 // mills between entries (reduce to take more/faster data)

// how many milliseconds before writing the logged data permanently to disk// set it to the LOG_INTERVAL to write each time (safest)// set it to 10*LOG_INTERVAL to write all data every 10 datareads, you could lose up to // the last 10 reads if power is lost but it uses less power and is much faster!#define SYNC_INTERVAL 1000 // mills between calls to flush() - to write data to the carduint32_t syncTime = 0; // time of last sync()

// Now we write data to disk! Don't sync too often - requires 2048 bytes of I/O to SD card // which uses a bunch of power and takes time if ((millis() - syncTime) < SYNC_INTERVAL) return; syncTime = millis();

// blink LED to show we are syncing data to the card & updating FAT! digitalWrite(redLEDpin, HIGH); logfile.flush(); digitalWrite(redLEDpin, LOW);