Instructables
video Automatic watering system
When you go out for a long time and have some plants at home, you may want to water them periodically. However if there is nobody else at home this task is very complicated. The solution is to make an automatic watering system where you can water your plants at regular intervals during a determinated lapse of time.

The components are:

1 PIC 16F628A
2 led
2 220 ohm. resistor
1 68K ohm. resistor
1 BC237 transistor
1 1N4148 diode
1 12 volts RA12W-K relay
1 push button
1 7805 dc-dc regulator
1 1000 uf capacitor
1 100 uf capacitor
2 terminals with 2 holes y 1 terminal with 3 holes.
2 double strips of three pins y 6 jumpers
1 power source 12 V. y 0,5A.
1 water level sensor
1 electric water pump

With jumpers strip you can change the watering interval and with the other jumpers strip you can change the watering durability. Also you can test the system with a button. When the water level is low, the sensor detects it and the pic don't turn on the water pump to protect it.

The code is written in C for CCS:

main.h
---------------------------------------------------------------------------------------------------------------------
#include <16F628A.h>

#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection

#use delay(clock=4000000)
#use fast_io(A)
#use fast_io(B)

#define CUANTAS 15
---------------------------------------------------------------------------------------------------------------------

main.c

---------------------------------------------------------------------------------------------------------------------
#include "main.h"

int inicio = -1;
int32 segundos = 0;
int interrupciones = CUANTAS;
int32 repeticiones[] = {7 * 24 * 3600, 6 * 24 * 3600, 5 * 24 * 3600, 4 * 24 * 3600, 3 * 24 * 3600, 2 * 24 * 3600, 24 * 3600, 12 * 3600};
int16 duraciones[] = {16000, 14000, 12000, 10000, 8000, 6000, 4000, 2000};

#INT_RTCC
void cronometro()
{
if(--interrupciones == 0)
{
++segundos;
interrupciones=CUANTAS;
}
}

#INT_RB
void nivel()
{
delay_ms(20);
if(input(PIN_B4) == 1)
{
output_high(PIN_A0);
output_low(PIN_A3);
}
else
{
output_low(PIN_A0);
}
}

#INT_EXT
void empiece()
{
delay_ms(20);
if(inicio == 0)
{
inicio = 1;
}
}

void main()
{
int contador;

set_timer0(0);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
port_b_pullups(TRUE);
set_tris_a(0);
output_low(PIN_A0);
output_low(PIN_A1);
output_low(PIN_A3);
enable_interrupts(INT_RTCC);
enable_interrupts(INT_RB);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
delay_ms(1000);
inicio = 0;

for(;;)
{
if(inicio == 1)
{
disable_interrupts(INT_EXT);
for(contador = 0; contador < 8; contador++)
{
if(contador % 2 == 0)
{
output_high(PIN_A1);
}
else
{
output_low(PIN_A1);
}
delay_ms(1000);
}

if(input(PIN_B4) == 0)
{
output_high(PIN_A1);
output_high(PIN_A3);
delay_ms(duraciones[input_b() >> 5]);
}
output_low(PIN_A1);
output_low(PIN_A3);
enable_interrupts(INT_EXT);
delay_ms(1000);
interrupciones = CUANTAS;
segundos = 0;
inicio = 0;

}
else if(segundos >= repeticiones[(input_b() & 0x0F) >> 1])
{
inicio = 1;
}
}
}
---------------------------------------------------------------------------------------------------------------------

You can watch the source code better in http://www.sistemasorp.es/2011/02/07/sistema-de-riego-automatico/ (spanish)
diy_bloke2 years ago
I see a waterpump, a plant, a waterreservoir and some electronics.
press a button-> pump starts
press another button pump stops

Just a flip switch can do that as well, without the electronics.
I am sure yr setup is really cool, but I'd hardly call it an instructable. As a matter of fact I dont even know what it does
zazenergy3 years ago
This looks really cool, but I wouldn't know how to build it based on your instuctable. Please include more information on "how" you built the system so we can do it at home!