Extended clock time for chicken coop door

Gaetano

New Member
Hello all
I am wanting to create a simple system that will close a sliding door to a chicken coop. Rather than use inputs from an LDR or switch or similar to activate the closing of the door I would like to link this function to a digital clock timer, the time frame would be 10 - 12 hours in duration. I know that the wait, pause, sleep commands could not be used. Would anyone know of any other methods of linking a clock timer to the closing of the door, thank you
Gaetano
 

lbenson

Senior Member
The easiest way is with a Real-Time-Clock (RTC) module like this:
http://www.ebay.com/itm/AVR-ARM-PIC-51-New-RTC-I2C-DS1307-AT24C32-Real-Time-Clock-Module-For-Arduino-/182358804483

or this:
http://www.ebay.com/itm/2PCS-DS3231-AT24C32-IIC-precision-Real-time-clock-module-memory-module-Arduino-/401051829692
(There are many variations).

I used one of these with an 08M2 to turn run my boiler with the pump on for all 3 heating zones for 6 minutes starting at 9:44 pm (21:44) using the following code:
Code:
' 08boilerRun.bas ds1307 rtc module
' turn on 3 boiler relays
' Note:  zone valves are 24V, .32A, 8W
' see 08boilerRun-pebble.txt
' uses ebay 4-relay module

#picaxe 08M2

symbol second = b1
symbol minute = b2
symbol hour = b3
symbol day = b5
symbol month = b6
symbol year = b7
symbol tempvar = b8
symbol loopCtr = b9

symbol Hi2cSCK=c.1
symbol Hi2cSDA=c.2
symbol pTest  =pinc.3
symbol pBoiler=c.4

pause 2000

HI2CSETUP I2CMASTER, %11010000, i2cslow, i2cbyte

' smhwdmy
'pause 2000
' hi2cout 0, ($00, $41, $20, $05, $29, $10, $16) ' smhwdmy

pause 5000

gosub getDate

sertxd ("Date is ", #year,":",#month,":",#day, 13, 10)
sertxd ("Time is ", #hour,":",#minute,":",#second, 13, 10)

do
  for loopCtr = 1 to 60
    nap 6 ' 1.1 seconds; was pause 1000
    if pTest = 1 then
      sertxd ("Boiler ON for testing", 13, 10)
      high pBoiler
      do while pTest = 1 : nap 6 : loop
      input pBoiler
      exit
    endif
  next loopCtr
  
  input pBoiler ' turn off if it is on

  gosub getDate
  sertxd ("Time is ", #hour,":",#minute,":",#second, 13, 10)
'  if hour => 20 and hour < 22 then
'    tempvar = minute // 5
'    if tempvar = 0 then
  if hour = 21 and minute > 44 and minute < 47 then
'  if hour = 9 and minute > 40 and minute < 45 then
      sertxd ("Boiler ON for 6 minutes", 13, 10)
      high pBoiler
      nap 12 : nap 12 : nap 12 : nap 12 : nap 12 ' ~5min
'      pause 60000 ' 5 times
'    endif
  endif
'  if hour = 15 and minute = 56 then
'      sertxd ("Boiler ON for 1 minute", 13, 10)
'      high pBoiler
''      nap 12  ' ~1min
'  endif
  if hour = 9 and minute = 36 then
      sertxd ("Boiler ON for 1 minute", 13, 10)
      high pBoiler
'      nap 12  ' ~1min
  endif
loop

end

getDate:
  hi2cin 0, (b1,b2,b3,b4,b5,b6,b7)
  bcdtoascii b5, b11, b12
  day = b11-"0"*10+b12-"0"
  bcdtoascii b6, b11, b12
  month = b11-"0"*10+b12-"0"
  bcdtoascii b7, b11, b12
  year = b11-"0"*10+b12-"0"
  bcdtoascii b1, b11, b12
  second = b11-"0"*10+b12-"0"
  bcdtoascii b2, b11, b12
  minute = b11-"0"*10+b12-"0"
  bcdtoascii b3, b11, b12
  hour = b11-"0"*10+b12-"0"
  return
The relay is turned on with the "HIGH pBoiler" command, and turned off with "INPUT pBoiler" (which makes the pin an input).

Not a great shot, but this is what my breadboard looked like (with an 08sim PCB module as shown here:
http://www.picaxeforum.co.uk/showthread.php?25538-08M2-and-14M2-SIP-boards-with-Eagle-PCB-files ):
08boilerRun.jpg

The code is somewhat complicated by some instructions I put in for testing. Something very similar should work for what you want to accomplish.
 
Last edited:

geezer88

Senior Member
My chickens are more tied to sunrise and sunset. How about a simple CdS photocell to control the door?

tom
 

tommo_NZ

New Member
Hello all
I am wanting to create a simple system that will close a sliding door to a chicken coop. Rather than use inputs from an LDR or switch or similar to activate the closing of the door I would like to link this function to a digital clock timer, the time frame would be 10 - 12 hours in duration. I know that the wait, pause, sleep commands could not be used. Would anyone know of any other methods of linking a clock timer to the closing of the door, thank you
Gaetano
Hi Gaetano,
I have been buying the RTC I2c modules off EBay for around NZ$1.30 each and find them to be very good in this kind of application.
 

Gaetano

New Member
Hello Ibenson
Thank you for taking the time to read and reply. I will consider your option when creating the design.
Gaetano
 
Top