Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
workshop
living
food
play
outside
Table of Contents
Arduino for Greenhouse, Garden or Growbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
Author:diy_bloke
I am a physician by trade. After a career in the pharmeceutical world I decided to take it a bit slower and do things I like. Other than my hobbies that involves
grassroots medicine in S.E.&P Asia. I have built low income cow dung bio-reactors, solar lamps and family fish ponds as well as houses out of every kind of
thinkable material. Instructables is an endless source of inspiration for my projects.
measure temperature
measure humidity of the air
measure humidity of the soil
measure water level in a container
measure light, basically to determine if it is light or day
switch a fan
switch a pump
switch a heater
switch a lamp
List of materials
Processor
Atmega 328 here to burn bootloader yourself or buy one preprogrammed
1x 28 pins IC foot narrow (or 2x 14 pins ic foot)
16MHz Crystal
2x 22 nF (often carries '223' imprint)
1x 10 k (brown-black-orange)
1x 100nF (often carries '104' imprint)
1x PCB momentary make switch
perfboard This is what I used because I had that laying around idle for years already
NOTE:an attractive alternative is a cheap arduino clone such as the Pro mini or Pro Micro that can be had for a few dollars at e.g. Dealextreme.com
Display
16x2LCD CG046-3007 A00, but any other will do.
1602 I2C module
PSU
1x 7805, isolated
1x 1N4001
2x 100uF (16 V en 25 Volt)
1x 1 k resistor (brown-black-red)
1x LED
1x psu connector
Peripherals
1x LDR
1x DHT11 moisture sensor (e.g. from dealextreme)
1x make push button
1x throw switch
1x buzzer (I use the CMB-06, a triggerable buzzer) ($2.99) but use any other buzzer you have or are comfortable with e.g. this one
1x NPN transistor (e.g.BC547)
1x 330 Ohm (orange-orange-brown)
2x 10k (Brown-black-red)
Solidstate relays
4x330 Ohm (orange-orange-brown)
4xLED
4x8pin dil foot
4x39MF22 SSR
4x2pin screw connector (mains voltage)
1x 5pin female printheader
1x 5pin male header 90degrees angle
ALTERNATIVELY: buy a ready made 4 channel mechanical relay for just about the same price as loose parts for the SSR, such as this one, or an even cheaper one.
bits and bolts
a couple of different colour wires, some print headers, four 3mm bolts and nuts, some 2.5 mm bolts and nuts, 4 spacers
solder tin, solder iron.
I have used Cinch plugs for connection... but actually these are hard to solder.
casing
I use two casings:
one for the processor and most of the peripherals (I use a plastic box that contained screws: 9x12x4.5 cm)
one for the SSR's (I used a Tic-Tac peppermint dispenser The bigger one for 100 mints: 8.5x2x5 cm)
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
Image Notes
1. indicating an empty reservoir
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
directly from a digital pin (capable of delivering 40 mA), but I just feel happier having some protection of the arduino pins.
The 5V1 zenerdiode between the analogue pin and the earth is to protect the chip against high voltages that may build up if a long line to the probe is used. It is optional.
The software has a routine that will read the voltage over the 10k resistor 5 times and then calculate an average.
Some tech stuff about soil humidity
When using a measurement like the one here, you are measuring resistance, or conductivity, depending on how you want to look upon it.
Conductivity is in fact not the best way to measure humidity of the soil as water itself is not really a good conductor, what you are actually measuring is the amount of
dissolved ions in your plant-bed. A not so moist soil with lots of ions may give you a higher reading for conductivity than a wet soil with less ions.
Measuring your ions of course is a useful thing too as it gives information on whether your soil is depleted and if maybe it is time to add fertilizer.
If you want a more reliable measurement of the humidity of your soil, then a capacitive measurement is more reliable: water influences the dielectric of a capacitor much
more than ions do.
A capacitor in your soil sounds like having two metal plates in your soil in which the soil in between them is the dielectric. That is certainly possible, but it is also possible
to have the plates of the capacitor next to each other instead of facing each other. That opens the way to etch them on a piece of PCB. Obviously the plates are isolated
from the soil, otherwise you would just be measuring conductivity/resistance again. That has the added bonus that there will be no soil corrosion.
So once you have that set up, there are two ways of measuring: you could just measure the capacity of your diy soil capacitor, as the arduino is perfectly capable of doing
that. The problem though is if you have a cable going from that sensor to your arduino, that is in fact a stray capacity that you are measuring as well. The way your cable
is looped may influence your reading as well as someone approaching your cable. Using coax will help, but it still is best to do the measurement close to your diy
capacitor.
Another way is to use that capacitor in a circuit whose output signal is depending on the value of your capacitor, such as a capacitor controlled oscillator. This can be
done with a Schmitt trigger as is shown in the picture above.
The frequency of that oscillator is:
f=1.2/(RxC)
A changing amount of water in the soil will affect the dielectric of the capacitor and therefore the value of the capacitor and thus the frequency coming out of the oscillator.
This frequency can be measured by the arduino with the frequency measuring library of the Arduino.
The value of the resistor depends on your situation. choose one that gives a good range of your frequency. The Arduino library supports frequncies to 8MHz.
If your capacitor is 10nF and your resistor 100kOhm, the frequency would be 1200 Hz. You will find a calculator here.
The FreqCounter.cpp file is hardcoded for digital pin 5 as input and uses both timer interrupts T1 and T2
Should you choose to use capacative measuring of the humidity, instead of using the various frequency counter libraries, you can also use 'PulseIn'. An example function
of how to do that can be found in the next step.
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
Of course the above program is only a proof of concept/test program: we are not interested in specific frequencies but in differences in frequencies/periods. You need to
determine for your soil what the right timing/frequency is for it to need water or not and incorporate that in your program the same way as previously you would have done
so fr the voltage divider probe on an anolog port. It is still possible to use the potmeter on A1 to set a level, e.g. by mapping it to your frequency range, or with some If or
Case statements.
To give an impression, when i tested it in my system (probes with about 6 cm distance, in so called 'Mel's Mix') a somewhat moist reading was 3kHz, while a wet soil
gave 10kHz
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
Image Notes
1. Reading of the probes in wet soil. This static pic suggests a stability that isnt
there, other readings might have been 9985
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
Image Notes
1. the leverswitch has a nylon string going through the hole in the wood and is
attached to a floating device
2. Cover for the switch
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
Step 10: Arduino for Greenhouse, Garden or Growbox: an alternative float switch
Determining whether the tank is empty is also possible with a reed switch as the figure shows: When the level drops to a specific amount, the magnet on the plunger will
close the switch and that will be signalling the Arduino that the pump should not be operated any more.
The disadvantage of this circuit is that eventually the reed switch will magnetize and go to a permanent closed position.Replacing the relatively cheap reed switch of
course will remedy that.
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
Step 12: Arduino for Greenhouse, Garden or Growbox: Solid State Relay
The 4 channel solid state relay is used to switch things like grow lights, a water pump a fan and a heater if necessary. It is almost a separate (albeit simple) project.
The circuit needs to be build 4 times and I have a print design available.
The circuit uses a 39MF22 solid state relay that simply needs a series resistor to limit the current. An LED shows whether the relay is active.
Because it is connected to 220 Volts, I have constructed it on a separate PCB and it is in a different case.
The 4 channels are controlled by digital pins 5,6,7 and 8 (Those are physicals pins 11-14 on the Atmega 328)
Inductive loads like the fan and the pump, may need a snubber network (100 Ohm resistor and 100nF capacitor in series over the connection). As these inductive loads
are only low power I have left them out and have not experienced any problems.
This part is fully described in an other instructable.
.
Warning
This device connects to a mains voltage. That can kill you. If you are not acquainted with working with high voltage circuits then do not build this
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
Image Notes
1. this jumper connects the backlight. ca be replaced by a female header attached
to a switch
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
Image Notes
1. to ssr/relay
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
Step 16: Arduino for Greenhouse, Garden or Growbox: The Software: code
/* measure soil moisture, if less than the set value switch pump
measure temperature, if less than set value, switch on heating
measure humidity, if higher than set value, switch on fan
<a href="http://www.quickgrow.com/gardening_articles/fans_air_movement.html"> <a rel="nofollow"> <a href="http://www.quickgrow.com/gardening_articles/fans_..
LCD commands:
lcd.setBacklight(LED_OFF);
lcd.noBacklight();
lcd.clear();
lcd.home();
*/
/*-----(
#include
#include
#include
#include
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
,
{
0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0
,
{
0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0
,
{
0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0
,
{
0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0
,
{
0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0
,
{
0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0
,
{
0x4,0x4,0x4, 0x4, 0x15, 0xE,0x4,0x0
}
};
/// -------- end creation-------------//The following function, "setup", must always be present
void setup()
{
Serial.begin(115200);
//upload defined characters to LCD
//---------------end upload---------------pinMode(levelPin,INPUT); // set level
pinMode(humidPin,INPUT); // measures humidity
pinMode(emptyPin,INPUT); // measures reservoir
pinMode(SwitchButton, INPUT);
// make Switch
pinMode(PushButton, INPUT);
// PushButton
pinMode(spikePin,OUTPUT); // for alternative supply to spikes
pinMode(pumpPin,OUTPUT); // Output for Relay
pinMode(fanPin, OUTPUT); // Output for fan
pinMode(hotPin, OUTPUT); // Output for heater
pinMode(lightPin, OUTPUT);// Output for light
pinMode(buzPin, OUTPUT); // Output for buzzer
digitalWrite(pumpPin, LOW);// Pump off
digitalWrite(spikePin, LOW);// moisture sensor off
digitalWrite(fanPin,LOW); // fan Off
digitalWrite(hotPin,LOW);
// heater off
digitalWrite(lightPin, LOW); // light Off
digitalWrite(buzPin, LOW); // buzzer off
/* Now LCD */
lcd.begin(16,2);
// initialize the lcd for 20 chars 4 lines, turn on backlight
int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));
for ( int i = 0; i < charBitmapSize; i++ )
{
lcd.createChar ( i, (uint8_t *)charBitmap[i] );
}
lcd.backlight();
// Print a message to the LCD.
lcd.setCursor(0, 0);
lcd.print("Greenhouse");
// ------- Quick 2 blinks of backlight -------------
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
flash(2);
// ------- Quick buzz-------------------------------buzz(1);
Wire.begin(); //needed for RTC, not for LCD
RTC.begin();
/* Set the date / time to the time this program was compiled.
Comment this OUT, AND upload, to let the clock just run. */
// RTC.adjust(DateTime(__DATE__, __TIME__));
}
/*----------------------------(end setup )---------------------*/
void loop()
{
DateTime now = RTC.now(); //Get the current data
// Serial.print("The year is ");
// Serial.print(now.year(), DEC);
// Serial.print(" Month = ");
// Serial.print(now.month(), DEC);
// Serial.print(" Day = ");
// Serial.print(now.day(), DEC);
// Serial.print(" Time = ");
// Serial.print(now.hour(), DEC);
// Serial.print(':');
// Serial.print(now.minute(), DEC);
// Serial.print(':');
// Serial.print(now.second(), DEC);
// Serial.println();
//------------end of RTC
// ---------- 1. Check if there is enough water ------------// check if there is water
level= digitalRead(emptyPin);
if (level==0) {
buzz(3);
delay(500);
}
//------------2. Read the soil moisture content/switch pump---------------/*
First read the level set with P1 on the levelPin and store that in 'irrigate'
*/
irrigate=sample(levelPin); //average of 5 readings
/*
LDR ----------------------------------------
/* ------------------Actions -------------------*/
//-------------5. DISPLAY DATA -----------------------------------/*
Display data on LCD */
push=digitalRead(PushButton);
if (push==1) // pushbutton not pressed
{
lcd.clear();
lcd.setCursor(0, 0); //set cursor on first line (line 0)
lcd.print("Temp.
: ");
lcd.print((float)DHT.temperature, 0);
lcd.print (char(1)); // prints degree sign
lcd.print("C");
lcd.print(" ");
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
lcd.print (char(7));
lcd.setCursor(0,1); //set cursor on 2nd line
lcd.print("Humidity: ");
lcd.print((float)DHT.humidity, 0);
lcd.print("%");
lcd.print(" ");
delay(1000); // wait for one second and then print the
lcd.setCursor(0,1);
lcd.print ("Irr. Level: ");
lcd.print(irrigate);
lcd.setCursor(0,0);
lcd.print("Moisture: ");
lcd.print(moist);
lcd.print("
");
soilmoisture
}
if (push==0)
// pushbutton pressed
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("licht: ");
lcd.print(light);
lcd.print("
");
lcd.setCursor(0,1);
lcd.print("licht niv.: ");
lcd.print(analogRead(LDRPin));
//buzz(1);
}
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
{
digitalWrite(buzPin, HIGH);
delay(250);
digitalWrite(buzPin, LOW);
delay(250);
}
return;
}
// This function will blink an LED a number of times for a specific duration
void ledblink(int times, int lengthms, int pinnum){
for (int x=0; x<times;x++){
digitalWrite(pinnum, HIGH);
delay (lengthms);
digitalWrite(pinnum, LOW);
delay(lengthms);
}
}
// This function maps the LDR reading into nrs 0-3
int Map(byte sens) {
// read the sensor:
int sensorReading = analogRead(sens);
// map the sensor range to a range of four options:
int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
// do something different depending on the
// range value:
switch (range) {
case 0:
//
// Serial.println("dark");
lcd.backlight();
break;
case 1:
//
// Serial.println("dim");
lcd.backlight();
break;
case 2:
//
// Serial.println("medium");
lcd.noBacklight();
break;
case 3:
//
// Serial.println("bright");
lcd.noBacklight();
break;
}
return range;
}
Step 17: Arduino for Greenhouse, Garden or Growbox: The Software: special characters
As I wanted a proper 'degree' character to use for Celsius (check yr LCD for character 123, perhaps that is suitable for you), I was in luck as the LCD allows for definition
of 8 user characters. Decided to make an arrow as well as visual indication of an empty tank. With regard to the definition of characters for the LCD, that is simple to do
with Malpartida's library On page http://custom-character.appspot.com/ you will find a 5x8 template that you can use to design your own characters. For the Arrow I
designed, the pattern as follows (white segment is '0', black segment is '1'). With the help of a binary - hex converter, one can then find the hex equivalent of the binary
number, but one can also directly send the binary number.
00100 -> 4
00100 -> 4
00100 -> 4
00100 -> 4
10101 -> 15
01110 -> E
00100 -> 4
00000 -> 0
Those binary numbers then can be send to the LCD with the help of the lcd.createChar function of the library. Of course one can also directly send the binary numbers
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
-Setting the threshold level for irrigation in the software with a button rather than with a variable resistor
-Adding various automated growth cycles to the program to chose from. Possibly stored in the EEPROM that comes with an RTC module).
-There is still an analogue port available. One could add an ntc to measure soil temperature, or a rain detector.
-Consider replacing the 4 solidstate relays by a ClickOn-ClickOff system that usually works on 433MHz, by adding a 433 MHz transmitter and sending the right codes.
The 433 MHz transmitter only needs 1 pin, freeing up 3. Ofcourse this is only useful if you feed the heater, fan, pump, lights with 110 or 220 Volt
After building this, i decided that having the LCD on, even if only at low light levels, wasnt the right choice, so i added a switch to just switch it on and off. The I2C module
i used for the LCD has a jumper to disconnect the backlight. A 2 pin female header attached to a switch will do that.
A better idea perhaps would be to add a proximity detector that switches on the LCD whenever someone comes close
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
Image Notes
1. DS1307
2. Pull-up resistors
3. Clock Crystal
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
B11111,
B01110
,
{
B00100,
B00100,
B01010,
B01010,
B10001,
B10001,
B10001,
B01110
,
{
B10001,
B10001,
B11111,
B10001,
B10001,
B10001,
B10001,
B10001
}
,
{
B01010,
B00100,
B00100,
B00100,
B11111,
B11111,
B11111
}
,
{
0x0, 0x4, 0xE, 0x15, 0x4, 0x4, 0x4, 0x0
}
,
{
0x4,0x4,0x4, 0x4, 0x15, 0xE,0x4,0x0
}
};
/// -------- end creation-------------//The following function, "setup", must always be present
void setup()
{
Serial.begin(115200);
//----RTC----#ifdef AVR
Wire.begin();
#else
Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
rtc.begin();
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
//----end rtc------//----Set sqw to 1 Hz--Wire.beginTransmission(0x68);
Wire.write(0x07); //move pointer to SQW address
Wire.write(0x10); // sends 010 (hex) 00010000 (binary)
Wire.endTransmission();
//---end sqw----pinMode(levelPin,INPUT); // set level
pinMode(humidPin,INPUT); // measures humidity
pinMode(emptyPin,INPUT); // measures reservoir
//digitalWrite(emptyPin, HIGH);
// turn on pullup resistors
pinMode(SwitchButton, INPUT);
// make Switch
pinMode(PushButton, INPUT);
// PushButton
pinMode(spikePin,OUTPUT); // for alternative supply to spikes
pinMode(pumpPin,OUTPUT); // Output for Relay
pinMode(fanPin, OUTPUT); // Output for fan
pinMode(hotPin, OUTPUT); // Output for heater
pinMode(lightPin, OUTPUT);// Output for light
pinMode(buzPin, OUTPUT); // Output for buzzer
digitalWrite(pumpPin, LOW);// Pump off
digitalWrite(spikePin, LOW);// moisture sensor off
digitalWrite(fanPin,LOW); // fan Off
digitalWrite(hotPin,LOW);
// heater off
digitalWrite(lightPin, LOW); // light Off
digitalWrite(buzPin, LOW); // buzzer off
/* Now LCD */
//---------------Set up LCD-----------------lcd.begin(16,2);
// initialize the lcd for 20 chars 4 lines, turn on backlight
//upload defined characters to LCD
int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));
for ( int i = 0; i < charBitmapSize; i++ )
{
lcd.createChar ( i, (uint8_t *)charBitmap[i] );
}
//---------------end upload---------------lcd.backlight();
// Print a message to the LCD.
lcd.setCursor(0, 0);
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
lcd.print("Greenhouse");
// ------- Quick 2 blinks of backlight ------------flash(2);
// ------- Quick buzz-------------------------------buzz(1);
Wire.begin(); //needed for RTC, not for LCD
RTC.begin();
/* Set the date / time to the time this program was compiled.
Comment this OUT, AND upload, to let the clock just run. */
// RTC.adjust(DateTime(__DATE__, __TIME__));
}
/*----------------------------(end setup )---------------------*/
void loop()
{
DateTime now = rtc.now(); //Get the current data
Serial.print("Het jaar is ");
Serial.print(now.year(), DEC);
Serial.print(" Maand = ");
Serial.print(now.month(), DEC);
Serial.print(" Dag = ");
Serial.print(now.day(), DEC);
Serial.print(" Tijd = ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
//------------end of RTC
// ---------- 1. Check if there is enough water ------------// check if there is water
// if not sound the buzzer
// later in the program the pump will be disabled
level= digitalRead(emptyPin);//Switch closed = empty
if (level==0) {
digitalWrite(buzPin, HIGH);
delay (50);
digitalWrite(buzPin, LOW);
delay(500);
}
//------------2. Read the soil moisture content/switch pump---------------/*
First read the level set with P1 on the levelPin and store that in 'irrigate'
*/
irrigate=sample(levelPin);
/*
Then we read the soil humidity sensor.
We'll first have to set the spikePin to HIGH, in case that is used to feed the sensor. After the reading we set it back)
If the value read ('moist') is smaller than what is considered dry ('irrigate') then the pump should be switched on for a specific time.
This is done by indicating a higher treshhold for switching the pump off
*/
digitalWrite(spikePin, HIGH);// put voltage on the humidity sensor
delay(100); //wait a short while
moist=sample(moisturePin); //read soil humiditySensor
//
digitalWrite(spikePin, LOW);
if (moist <= irrigate){
pump=1;
digitalWrite(pumpPin, level); // if the reservoir is empty a 0 will be written
}
if (moist >= irrigate+5) {
pump=0;
digitalWrite(pumpPin, LOW); // prevents Jitter
}
//-------------3. Read the DHT11 humidity/temp sensor----------------// now we measure temperature and air humidity
// READ DATA
// Serial.print("DHT11, \t");
int chk = DHT.read11(DHT11_PIN);
switch (chk)
{
case DHTLIB_OK:
//
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
Serial.print("Time out error,\t");
break;
default:
Serial.print("Unknown error,\t");
break;
}
//-------------4. Read LDR ---------------------------------------light=Map(LDRPin);
/* ------------------Actions -------------------*/
//-------------5. DISPLAY DATA -----------------------------------/*
Display data on LCD */
push=digitalRead(PushButton);
if (push==1) // pushbutton not pressed
{
lcd.clear();
lcd.setCursor(0, 0); //set cursor on first line (line 0)
lcd.print(char(2)); //prints thermometer
lcd.print(" ");
lcd.print((float)DHT.temperature, 0);
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
byte k;
for=(k=0; k<u;k++)
digitalwrite(buzpin, high);
delay(200);
digitalWrite(buzPin, LOW);
delay(200);
}
return;
}
// This function will blink an LED a number of times for a specific duration
void ledblink(int times, int lengthms, int pinnum){
for (int x=0; x<times;x++){
digitalWrite(pinnum, HIGH);
delay (lengthms);
digitalWrite(pinnum, LOW);
delay(lengthms);
}
}
// This function maps the LDR reading into nrs 0-3
int Map(byte sens) {
// read the sensor:
int sensorReading = analogRead(sens);
// map the sensor range to a range of four options:
int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
// do something different depending on the
// range value:
switch (range) {
case 0:
//
// Serial.println("dark");
// lcd.backlight();
break;
case 1:
//
// Serial.println("dim");
// lcd.backlight();
break;
case 2:
//
// Serial.println("medium");
// lcd.noBacklight();
break;
case 3:
//
// Serial.println("bright");
// lcd.noBacklight();
break;
}
return range;
}
void printDigits(int digits) { //this adds a 0 before single digit numbers
//if (digits >= 0 & digits < 10) {
if (digits <10) {
lcd.write('0');
}
lcd.print(digits);
}float tempConvert(float celsius)
{
float fahrenheit = 0;
fahrenheit = (1.8 * celsius) + 32;
return fahrenheit;
}
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
}
void loop(){
//other stuff
}
Keep in mind though that if you would set a timer such that your soilhumidity would be read every 10 minutes, that if there is need to switch the pump on, you need to
read the soil humidity constantly, otherwise your pump will flow for at least 10 minutes, before another reading is taken. That may be too much water.
Related Instructables
Clock with
thermometer
using Arduino,
i2c 16x2 lcd,
DS1307 RTC
and DHT11
sensor. (Photos)
by Timofte Andrei
Arduino Real
Time Clock
(DS1307) by
Naren_Murali
Weekend
project clock
date
thermometer
and humidity
with Arduino
mega by arick
Mostrar
Temperatura en
Display con
Sensor DHT11 y
Arduino by
ElectroCrea
Build yourself a
clock and
thermometer by
arick
Clock ,RTC
DS1307 SET
AND SHOW THE
TIME ON YOUR
LCD. by citin
Advertisements
Comments
11 comments Add Comment
diy_bloke says:
my pleasure Akin
caixinhadeleite says:
diy_bloke says:
acheide says:
diy_bloke says:
That's a nice project! I would use your project to create my own watering system :D thanks for sharing
diy_bloke says:
henriveil says:
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/
BLR_RAVI says:
diy_bloke says:
Thanks BLR_Ravi :-)
http://www.instructables.com/id/Arduino-for-Greenhouse-Garden-or-Growbox/