Introduction: Grow Your Plant With Linino

Some time ago I and my friend (Rocco88) had the possibility to know and play with a very good system, Cynara.

It's a single spot rgb LED lamp that grows medium size plants, particularly vegetables and kitchen herbs.

The best feature of this system is the low power consumption, 7 W, but is it possible to limit consumption further? Certainly. Just take advantage of the light already present in our environment, simply by turning off the lamp when ther's enough light. Use an Arduino Yun or Linino one to automate everything and you're done. See and use the instructions that follow.

Now we could also automate the watering system of our plant to have everything under control...and then what is left to be done is sit down and enjoy our plant grow beautifully.

An important requirement is to know the Linino's world. Visit the website to find all the necessary information for a correct set up of your Arduino Yun / Linino One. See http://www.linino.org/ and the wiki page.

Step 1: Functioning

The system is set to remain active over a programmable time, for example from 8:00 to 18:00. In this period, if the light sensor does not detect the light needed to grow the plant the lamp will light on, otherwise it will stay or be turned off.

The plant watering is programmed to be executed once a day, for a pre-determined and programmable time. It obviously depends on the amount of water the plant need (for our primrose ten seconds of water every day was enough).

Step 2: What You Need

* Arduino Yun / Linino One

* Cynara Lamp

* Light Sensor

* Water Pump

* Relay Module SainSmart 2ch 5v

* Shield TinkerKit 2.0 ( you can also use a simple breadboard )

Step 3: Connect

Connect all the components as described in the schema of the project. We used tinkerKit shield 2.0 because having it, was convenience. The connectors on the shield match those specified in the code. Output 04 -> pin D5 (water pump), 02 -> D9 (cynara lamp), Input I5 -> A5 (light sensor). You can also use a breadboard and set the appropriate connections.

Step 4: Coding

Create a new project in Ideino IDE, choose name and modify files package.json and server.js as follow:

package.json ( you can customize the fields name, version, description and author with your information)

{"name": "Ideino Project",
  "version": "0.0.1",
  "description": "Ideino example project",
  "author": {
    "name": "Ideino Team"
  }
}

server.js and that's it ! Read comments in the code to know what to change to adapt the system to the needs of your plant.

    var linino = require('ideino-linino-lib'),    
    board = new linino.Board(),
    light = board.pin.analog.A5,   //a5 --> I5 light sensor   
    lamp = board.pin.digital.D9,   //D9 --> 02 lamp
    water = board.pin.digital.D5,  //water
    active = 1,
    waterOn = 0,
    waterTime = 10000, // set water time
    dayWater = '0',
    day = '0'; 
 
// function to convert time in a convenient format, for example 10:03 will be 1003, 8:00 will be 800. 
function addZero(i) {
                if (i < 10) {
                    i = "0" + i;
                }
            return i;
}

// function to check system time
function checkTime (){    
 var d = new Date();
 day = d.getDate();
 var h = d.getHours();
 var m = addZero(d.getMinutes());
 var time = Number(h+1 + '' + m); // added +1 to h for italian time now     
        if (time >= 800 && time <= 1800) {      
// time of System ON, now it will be active from 8:00 to 18:00
            active = 1 ;
         }
         else {
            active = 0; 
             console.log('System OFF');
             board.digitalWrite(lamp, board.LOW); // turn off the lamp, system OFF
      } console.log('Time: ' + Number(h+1) + ':' + m);
      
      if (time >= 1700 && time <= 1800) {  // time of water, now between 17:00 and 18:00  
            waterOn = 1 ;
         }
         else {
            waterOn = 0; 
        }
}

board.connect(function(){      
board.pinMode(lamp, board.MODES.OUTPUT);
board.pinMode(water, board.MODES.OUTPUT);
checkTime();    // first check system time    
board.analogRead(light, function(value){
        console.log('Light Sensor Value: ' + value);
        if (active === 1){
                console.log('System ON');
                if (value < 100){
                    board.digitalWrite(lamp, board.HIGH);  // light the lamp
                }
                else {
                    board.digitalWrite(lamp, board.LOW);  // turn off the lamp
                    }
        } else {
                    board.digitalWrite(lamp, board.LOW);  // turn off the lamp
                }  
    });        
        
    // Check system time    
    setInterval(function() {
    checkTime();  
    if (waterOn === 1 && dayWater != day){  // This control allow to water one time at day
            console.log('It is time to water, I do for '+ waterTime/1000 + ' seconds');
            board.digitalWrite(water, board.HIGH);
                setTimeout(function() {
                    board.digitalWrite(water, board.LOW);
                    waterOn = 0;
                    console.log('Stop water now');
                    done = true;
                    dayWater = day;
                }, waterTime);  // waterTime specific time of watering, set it in global variables
        }  
    },61000);  // Time to update check system time and water time, 61 seconds now
    
});

Step 5: Conclusions

This project is designed to allow everyone to be able to grow a plant in environments usually difficult and poorly lit, including his own apartment. In particular Cynara is designed primarily for growing herbs that we use every day in the kitchen and that difficult we can found in period as winter. We are sure that your food will taste special.

Step 6: About Linino & Cynara