Pages: 1 [2]   Go Down
Author Topic: YATC - Yet Another Terrarium Controller  (Read 4944 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.


* IMG_0804.jpg (220.62 KB, 2048x1365 - viewed 11 times.)
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 50
Posts: 3429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-wink
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-wink

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 smiley

I have replaced the RTC with an GPS Clock and added some additional "timers"
Code:
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:
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:
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 smiley 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:
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

« Last Edit: February 06, 2013, 04:47:14 pm by dafes » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-wink

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" smiley
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:
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;   
}
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12483
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 -
Logged

Rob Tillaart

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

Pages: 1 [2]   Go Up
Jump to: