My Garduino Project 3 Box design

Hi. I have a project ive been working on before. This is my very first arduino project. I am having a little trouble with my code and would like to see if anyone would have any interest in helping me out or give suggestions on my coding or wiring. Thank you.

Growduino_v5.zip (26.6 KB)

I am sure that you will get a lot of help, but you need to be more specific - What is your program supposed to do? What is the problem? What have you already done to try and fix it?

My Project is a 3 box grow-box for any kind of plants. It is two small boxes and one large box. Each have their own DHT11 (Temp/Humidity) sensor, very basic moisture sensor made from nails and resistors, and am still debating the other sensor i should use but I have it labeled in my sketch as a light sensor. All three boxes are lit by a custom LED panel composed of 100+ SMD LED strips of red and blue and have a split light socket for normal incandescent of CFL bulbs. There is an exhaust system made of PC fans and the cooling system is made from an old wine cooler box And there is a pump and drain system all witch are controled by an 8 relay module connected to my arduino.

My problem is my timing and other little bugs with my serial menu. Since i don't have a RTC then the time has to be set manually and the lights wont turn on/off according to my timing throughout the day. My GOAL is to make this thing take care of itself for at least a week straight. watering when the soil is dry and turning off the lights on schedule and maybe in the future making it log all activity.

The full code is attached on the first post

You've got hundreds of LEDs, temperature and humidity sensors, moisture sensors, pumps and relays. How about spending $9 and get a clock?

I am going to buy one soon but i don't think the problem is 'the time' but more of the 'timing code'. This is my first time programming anything and i'm sure my 'grammar' isn't the greatest . The arduino will function properly for around 8 hrs and then only 1 or 2 boxes work then just one after a day day and a half. The arduino IDE will let me compile it so i know it works, just not for very long.

and i want this for my time

float start_time;
float seconds_elapsed;
float seconds_elapsed_total;

Times should really be unsigned long.


  timeCurrent=millis();
  if(timeCurrent<*timeMark) {  //Rollover detected
    timeElapsed=(TIMECTL_MAXTICKS-*timeMark)+timeCurrent;  //elapsed=all the ticks to overflow + all the ticks since overflow
...

 if(timeElapsed>=timeInterval) {

You don't need to worry about overflow if you subtract. eg,

 if(millis () - timeMark > timeInterval) {

You can save quite a bit of RAM by using the "F" macro for your string literals.

eg.

Instead of:

  Serial.println("Diag Mode is Running ");

Use:

  Serial.println(F("Diag Mode is Running "));

Using too much RAM might cause it to crash.

Thank you very much. I will try your suggestions and let u know.

What exactly does the 'F' macro do to save ram.
And should i use the 'F' macro on ALL the serial.print and serial.println?

Those strings are already in program memory. It simply stops them being copied into RAM, of which you have a lot less.

Effectively the macro expands out to a bit of code that accesses the string directly from program memory rather than RAM.

rcash88:
And should i use the 'F' macro on ALL the serial.print and serial.println?

Yes, all the literal strings. There is no point for variables, which, well, vary.

Examples ...

Do this:

  Serial.println(F("Diag Mode is Running "));
  Serial.println(F("This will loop until other command recieved"));
  Serial.println(F("15 Seconds to push another menu item"));

But not:

  Serial.print(F(Fahrenheit(t1)));

That's because that is not a literal string.

One of the best F() macro explanations so far...