These names are a clue that you can refactor: TemperatureControlT1, TemperatureControlT2. Consider making these a single function and pass the specific terrarium parameters, either as individual arguments or as a struct (or pointer to one) so that the same code can serve many terrarium instances. Alternatively, you could go full OO and just build a class that controls a terrarium - never thought I'd use that word so many times in a single post

Yes i thought about it. I thought also about a Struct Terrarium object with its Sensors. In the first step i want to build it as simple as possible to get the job done

I have replaced the RTC with an GPS Clock and added some additional "timers"
long Seconds30Interval = 30000; //30 Secons //Intervall in miliseconds
long previous30SecondsMillis = 0; // will store last time CheckForSomethingtoDo was running
long Minute1Interval = 60000; //1min //Intervall in miliseconds
long previous1MinuteMillis = 0; // will store last time CheckForSomethingtoDo was running
long Minute5Interval = 300000; //5min //Intervall in miliseconds
long previous5MinuteMillis = 0; // will store last time CheckForSomethingtoDo was running
long Hour1Interval = 3600000; //1hour //Intervall in miliseconds
long previous1HourMillis = 0; // will store last time CheckForSomethingtoDo was running
This will give mne some freedom.
At the moment i stuck at the Day Night things:
I created a function which Adjusts the DayNightRhythm according the month:
void SetDayRhythm_T2()
{
if(GPS.month == 0){
if(DEBUG) {Serial.println("Debug:SetDayRhythm_T2 GPS.month == 0");}
return;
}
if(DEBUG) {Serial.print("DEBUG: SetDayRhythm_T2 Month:");Serial.println(GPS.month,DEC); }
switch(GPS.month)
{
case 1:
T2_DayStart = 915; //09:15
T2_DayEnd = 2015; //20:15
T2_SpotStart = 140; //14:00
T2_SpotEnd = 200; //20:00
break;
.....
....
....
case 12:
T2_DayStart = 100; //10:00
T2_DayEnd = 200; //20:15
T2_SpotStart = 1600; //16:00
T2_SpotEnd = 1700; //17:00
break;
}
}
This is a litle dirty but it does the job. In the 30seconds function i got an Verify if its time to Start/Stop a Lamp or Spot
void _CheckForSomethingtoDoTerrarium1_30Seconds()
{
String time = String(GPS.hour)+=String(GPS.minute);
if(DEBUG) {Serial.println("Debug: _CheckForSomethingtoDoTerrarium1_30Seconds Time: ");Serial.println(time); }
if(time == String(T2_DayStart))
{
if(DEBUG) {Serial.print("Debug: T2_DayStart Time: ");Serial.println(time); }
return;
}
if(time == String(T2_DayEnd))
{
if(DEBUG) {Serial.println("Debug: T2_DayEnd Time: ");Serial.println(time); }
return;
}
if(time == String(T2_SpotStart))
{
if(DEBUG) {Serial.println("Debug: T2_SpotStart Time: ");Serial.println(time); }
return;
}
if(time == String(T2_SpotEnd))
{
if(DEBUG) {Serial.println("Debug: T2_SpotEnd Time: ");Serial.println(time); }
return;
}
}
Yes i use strings.. i will replace them a soon as possible

this is just a habit from c#.
Anyway has anybody a solution for a dynamic Terrarium struct which includes a "array" or "list" of sensors(a sensor is an 8 byte array)
byte sensor1[8] = { 0x10, 0xB2, 0xA0, 0x54, 0x2, 0x8, 0x0, 0x4E };
How can i walk thorugh such a array of sensors?
Edit: Is the String Problem still present? I have read some post that this was prior 1.0:
http://code.google.com/p/arduino/issues/detail?id=468&q=string&sort=-idhttp://stackoverflow.com/questions/12930978/array-of-strings-char-array-in-c-arduino-how-do-i-accomplish-it