Gardening is very long task taking time every day.
For this tutorial I remix 3 of my old project the iot farm, the automated farm and the cocktail machine I took the ikea furniture
I will provide a guide on how to control your plant remotly or with a code , for me I used both to get full advantage of both !
Order:
Ethernet shield arduino (wifi could be better)
- Relay
- Wire I like these wire they are already cut in different size but it's optional
- Pipe
- FAN I used the one from an old computer: (zalman)
- Light
- Soil moisture
You can also add temp sensor, humidity etc I won't cover to make it simple as possible.
Step 2: Setting Up the ArduinoThe schema is pretty simple the fan, light and water pump goes to the relay and the soil moisture to A0
Soil moisture:
To check if the plants need water
VCC: 5v
GND:GND
A0: A1
The Fan:In this scenario it will activate automatically everyday for few minute to give some fresh air
The water pump:It will activate with the soil moisture.
the + goes to midlle on the relay and GND to GND of the power source
LIGHT:
I set up to be activate 1 hour a day.
The anode(+) goes to the relay The other to the GND of the power supply
Important for the relay I used only one 12v power supply, I separate the wire positive and negative then solder 3 wire from the positive and connect each part on the relay.
One is enough as everything does not turn on at the same time.
I used a 5v power supply for the arduino RELAY:
VCC: 5V
GND: GND
IN1: PIN3 Activate the light
IN2: PIN5 Activate the water pump
IN3: none
IN4 PiN4: activate the FAN
Step 3: Cayenne Pre RequiredHere we gonna see how to configure cayenne which is very easy.
First create an account Here.
Then you should have you ethernet shield with Rj45 cable connected.
Here is the code to connect to cayenne included with the code for the water pump.
This code work for the w5100 shield for other ethernet/wifi shield the code is on cayenne
Also don't forget to add your token you get it after creating your account.
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);
}
}
Step 4: Configuration CayenneWe almost done for arduino and now it's the easy part.
We gonna add all the devices on cayenne check the picture.
1) GO to add device
2) Custom widget
3) Select the kind of widget you like.
(exact configuration shown on picture)
Relay:Same procedure but this time in actuators then select the pin of the arduino connected to the relay for the light/fan/water pump
Step 5: Event and TriggerYou can see from the pictures the configuration to manage light and fan you can also setup the water pump !
Event:I set up 4 Event one to start the light and one to stop it in the evening And 2 for the fan on/off.
Step 6: Full CodeFor my case the fan and the light work with cayenne and I set up the water pump with code to activate when the plant need water.
I used both because from my experience work better that way.
However if you don't want to use a platform here is the full code to manage the 3 equipment.
to adjust the the time you wante the light/fan on just edit the variable
long OnTime = 3600000; // milliseconds of on-time FAN modify here<br>long OnTime1 = 3600000;
long OffTime = 60000; // milliseconds of off-time FAN modify here
long OffTime1 = 60000;
And here the full code it can be largely impoved !
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);
}
}
Ps: For this code the fan is connected to digital pin 2 not 3
In this project the purpose was to create quickly an automated installation for a plant.
I made a hole on the top to put the funnel wich is link to the container for the water so I need to move anything!
The design is not my best part I will try to improve it in the future.
Advice:The ethernet shield can get the error dhcp fail when tryng to connect I found the solution on arduino forum You have to solder two 100ohm resistor If you liked the instrucable pleaase let me know !
Comments
Please log in or sign up to comment.