Thomas sxt
Published © CERN-OHL2

IKEA Smart Plant

Gardening is very long task taking time every day.

BeginnerFull instructions provided2 hours711
IKEA Smart Plant

Things used in this project

Story

Read more

Schematics

schema automatic garden

Code

Code snippet #1

Plain text
int PROBE= 1;<br>int value= 0; 
int sensorPin = A0;   // select the input pin 
int sensorValue = 0; 
//#define CAYENNE_DEBUG         // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <cayenneethernet.h></cayenneethernet.h></p><p>// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token[] = "yourtoken";</p><p>void setup()
{
 Serial.begin(9600);
  Cayenne.begin(token);
}

void loop()
{
  Cayenne.run();
//code water pump
 value= analogRead(PROBE);  
 value= value/100;  //divided by 100
 Serial.println(value);  
 if(value>5)  //modify here the value
 {  
     
   digitalWrite(5, HIGH);  
     
 }  
 else  
 {  
   digitalWrite(5, LOW);  
 }
   }

Code snippet #3

Plain text
int PROBE= 1;
int value= 0; 
int TIP120pin = 3; //for this project, 
int TIP120pin1 = 3;
int ledState = LOW;             // 
int ledState1 = LOW;
unsigned long previousMillis = 0;        // will store last time LED was updated
unsigned long previousMillis1 = 0;
long OnTime = 12960000000000;           // milliseconds of on-time FAN modify here
long OnTime1 = 75600000;           
long OffTime = 60000;          // milliseconds of off-time FAN modify here
long OffTime1 = 10800000;	// temps que dois rester allumer la lampe
 int sensorPin = A0;   // select the input pin 
int sensorValue = 0;  // variable to store the value coming from the sensor
void setup() 
{
  // set the digital pin as output:
  pinMode(5,OUTPUT);
  pinMode(TIP120pin, OUTPUT); // Set pin for output to control TIP120 Base pin  
  pinMode(TIP120pin1, OUTPUT); // Set pin for output to control TIP120 Base pin 
  pinMode(4, OUTPUT);
  pinMode(2, OUTPUT); //pin connected to the relay
  Serial.begin(9600); //sets serial port for communication
}
 
void loop()
{
  // check to see if it's time to change the state of the FAN
  unsigned long currentMillis = millis();
 
  if((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
  {
    ledState = LOW;  // Turn fan off
    digitalWrite(4,LOW);//tur off the relay
    previousMillis = currentMillis;  // Remember the time
    digitalWrite(TIP120pin, ledState);  // Update
  }
  else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime))
  {
    ledState = HIGH;  // turn fan on
    digitalWrite(4,HIGH);// turn on the relay
    previousMillis = currentMillis;   // Remember the time
    digitalWrite(TIP120pin, ledState);    // Update 
  }
  //code for the light
   unsigned long currentMillis1 = millis();
  
 if((ledState1 == HIGH) && (currentMillis1 - previousMillis1 >= OnTime1))
  {
    ledState1 = LOW;  // Turn fan off
    digitalWrite(2,LOW);//tur off the relay
    previousMillis1 = currentMillis1;  // Remember the time
    digitalWrite(TIP120pin1, ledState1);  // Update
  }
  else if ((ledState1 == LOW) && (currentMillis1 - previousMillis1 >= OffTime1))
  {
    ledState1 = HIGH;  // turn fan on
    digitalWrite(2,HIGH);// turn on the relay
    previousMillis1 = currentMillis1;   // Remember the time
    digitalWrite(TIP120pin1, ledState1);    // Update 
  }
//code water pump
 value= analogRead(PROBE);  
 value= value/100;  //divided by 100
 Serial.println(value);  
 if(value<5)  //modify here the value
 {  
     
   digitalWrite(5, HIGH);  
     
 }  
 else  
 {  
   digitalWrite(5, LOW);  
 }
  
}

Credits

Thomas sxt
7 projects • 24 followers
🔩Maker Arduino Rasp. 🖨️3DPrint/design creation ! My STL:https://cults3d.com/fr/utilisateurs/diyfunproject 📲WEBSITE:diyfp.fr/thomassxt
Contact

Comments

Please log in or sign up to comment.