' 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