Go Down

Topic: YATC - Yet Another Terrarium Controller (Read 7486 times) previous topic - next topic

volshebnick

Hi there.
I think you also need a great enclosure to fit your arduino, buttons, lcd, etc.
Take a look at this topic: http://arduino.cc/forum/index.php/topic,141660.0.html
Let me know if you decided to get one, we will customize size and cut needed windows for you. I think a cherry wooden one will look pretty nice with terrarium.

wildbill

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  ;)

dafes

#17
Feb 06, 2013, 10:40 pm Last Edit: Feb 06, 2013, 10:47 pm by dafes Reason: 1

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"
Code: [Select]

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:
Code: [Select]

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
Code: [Select]

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)
Code: [Select]
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=-id
http://stackoverflow.com/questions/12930978/array-of-strings-char-array-in-c-arduino-how-do-i-accomplish-it


dafes


Quote
I have two Terrariums so i need a Modular Controller to inependently Controll both.


Why not two UNO's in stead of one MEGA?  Modular is modular ;)

Quote
and simulate Sun Rising/ Falling

I discussed an algorithm here - http://arduino.cc/forum/index.php/topic,66426.0.html - might be useful

(you can also connect an LDR to the window and "read the local sunset/rise" :)

Hi,
i have read the Post and created a function according to this Post. the Location is Sydney (Because of UpsideDown i switched December with June to match the local Time.
Lat:
-33,52,0
Long:
-151,13,0


Sunries @23 June = 7:00 = 60 * 7 + 0 =420
Sunrise @23 dec = 4:42 = 60*4 + 42 = = 282
average = (=420+282)/2 = 351
delta = =420- 282= 138 => divide by 2 makes 69

Sunset @23 Dec 7:06PM = 60 * 19 + 6 = 1146
Sunset @23 June 4:54PM = 60*16 + 54 = 1014
average = (1146+1014)/2 = 1080
delta = 1146 - 1014= 132 => divide by 2 makes 66



Code: [Select]

void getRiseSet()
{
  float common = 69 * cos( ((month-1)*30.5+dayOfMonth + 8 ) * 0.017214206) ;  // replace division with faster multiplication
  sunrise = 351 + common;
  sunset = 1080 - common;   
}

robtillaart

Formula looks good.
Run it in a loop from day 1 to day 365 and check it against some website: - http://www.timeanddate.com/worldclock/astronomy.html?n=240 -
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up