Customer Check-In

NewImage

 plant key:

genovese basil parsley sweet basil stevia stevia lettuce
genovese basil thyme sweet basil stevia stevia kale

Ooh! Starting to see roots:

NewImage

Open Source

The Arduino code – TheLeafSpa.ino –  I used for this post is located at this GitHub location.

Testing…

ChallengesBringOpportunites Yippee!

Logfile Results

The Leaf Spa doesn’t have a UI.  Rather, I log readings and actions onto a file on the SD Card (I went over what I’m doing code wise in this post)  I’m getting expected results when testing the Grow Chamber.  Here is a snapshot of some of the data logged:

NewImage

Feeding the CSV file into a Google Spreadsheet, here is a partial table:

Row ID Date Time Temp (˚C) Humidity CO2 PPM
51 2/28/2017 9:53:00      
9 2/28/2017 9:53:00      
51 2/28/2017 9:53:20      
9 2/28/2017 9:53:20      
10 2/28/2017 9:56:20      
3 2/28/2017 9:56:20      
0 2/28/2017 9:56:20 22.7 54.7 379
5 2/28/2017 9:56:20      
1 2/28/2017 9:56:20      
2 2/28/2017 9:56:25      
6 2/28/2017 9:56:30      
0 2/28/2017 9:57:20 22.5 54.6 1077
5 2/28/2017 9:57:20      
1 2/28/2017 9:57:20      
6 2/28/2017 9:57:25      
2 2/28/2017 9:57:25      
0 2/28/2017 9:58:20 22.8 54.7 1253

I added the header to the file.

Row ID

The RowID comes from the logRow_t enum in TheLeafSpa.ino 

enum logRow_t {
  SensorData,   //0
  PumpOn,       //1
  PumpOff,      //2
  LEDOn,        //3
  LEDOff,       //4
  CO2On,        //5
  CO2Off,       //6
  CardInserted, //7
  CardRemoved,  //8
  WarmupStart,  //9
  WarmupEnd,     //10
  Settings_V1 = 51 //51 will be the number used to identify the logfile contains sensor readings and actions
                //based on globalSettingsV1_T variables
} ;

back to the rows on the spreadsheet above.   The first two rows point to a start that was quickly abandoned.  This points out the log file appends new entries.  My intent with not deleting an older run is to favor the person who takes the SD Card out to read from a Mac/PC the ability to delete older results.

Starting with the third row, the 51 for the row type points to a row about the version of settings used:

void writeSettingsVersionToLogFile() {
  File logFile = openFile();
  if (!logFile) {
    DEBUG_PRINTLNF("Could not write settings data. Log File could NOT be opened!");
  } else {
    String settingsString = String(20);
    settingsString = String(Settings_V1) + ",";
    settingsString += getDateTimeString() ;
    DEBUG_PRINTF("Settings String: ");
    DEBUG_PRINTLN(settingsString);
    logFile.println(settingsString);
    logFile.flush();
    logFile.close();
  }
}

Row ID 9 lets us know The Leaf Spa’s firmware is warming up.  This is to accommodate the three minutes of warmup discussed on the wiki page for the Grove CO2 Sensor.  The time the date/time the firmware starts warming up is 9:53:20 on February 28, 2017.  Row ID = 10 (warmup is finished) has a time stamp of 9:56:20 – three minutes after the start of warm up.

Row ID=3 lets us know the LEDs were turned on immediately after warm up.  The firmware logic:

void turnLightOnOrOff() {
  //light is off between 00:00:00 and 3:59:59
  if ( (hour() >= globalSettings.hourToTurnLightOff) && (hour() < globalSettings.hourToTurnLightOn) ) {
    turnLightOff();
  } else {
    turnLightOn();
  }
}

uses the settings for the hours the lights should be on or off to determine if the LED should be on or off when the firmware starts up.  This sets up the photoperiod. 

Row ID 0 is a sensor reading.  For now, no action is taken based on the readings for temperature and humidity.  Action is taken based on the CO2 level.  If the CO2 level is below 1200 ppm, the firmware will turn on the CO2 tank’s valve and CO2 will be released into the Grow Chamber.  It is assumed the valve is at a low level.

void adjustCO2() {
  if (fLEDon) {
    int CO2Value = takeCO2Reading();
    if (CO2Value > 0 && CO2Value <= 1200) { // -1 is returned if the sensor isn't working correctly.
      //Got a good reading that is below 1200 ppm so turn on the CO2.  It is assume the valve is opened just
      //a little bit. Leave the valve on for less time as the value gets closer to 1200
      int nSecondsValveIsOpen=0;
      CO2Value < 800 ? nSecondsValveIsOpen=10 : nSecondsValveIsOpen=5;
      writeEventHappened(CO2On);
      digitalWrite(CO2Pin, ON);
      Alarm.timerOnce((const unsigned long)nSecondsValveIsOpen, turnCO2Off);
    } else {
      DEBUG_PRINTLNF("The LED is off - no need to adjust");
    }
  }
}

Row ID 1 and 2 show when the water pump was turned on and off.  

  globalSettings.amtSecsWaterPumpIsOn = (DEBUG == 1) ? 5 :  60; //amount of seconds for pump to be ON.
  globalSettings.secsBetweenTurningPumpON = (DEBUG == 1) ? 60 :  30 * 60; //# secs between turning pump ON.

The settings vary depending if the firmware is running in debug mode.  This test was run in debug mode.

 

…so …yah…I’m happy with the results.  It’s almost time to give the plants a new home!

Advertisements