- Sat Dec 03, 2016 7:03 pm
#59061
I did something similar using the olimex esp module to sound off a PA system bell sound for our shop to indicate break times, lunch, cleanup, etc. The olimex board has a relay and esp on one little board. Here is the link.
https://www.olimex.com/Products/IoT/ESP8266-EVB/open-source-hardwareI bought it from amazon for $15.00. The PA system has a dry contact input to sound a "bell", which is a series of different tones that lasts for about 4 seconds, so I do that twice in the [dorelay] sub because the shop is pretty loud sometimes. Here is the link for the PA unit.
https://www.vikingelectronics.com/product-details.php?pid=317#Also, at 1 in the morning, it updates the time to keep it current. I have 7 different times you can store but you can add many more very easily and also save them in case of power failure. I am sure that this could also be used with the sonoff with proper pin changes, etc. and you can add some fancy things like the original poster did. This is just another simple way to do time based things.
Code: Select allmemclear
cls
relay = 5
LED = 1
blink = 1
tz = -8
DST = 0
for x = 1 to 20 'show blinky at startup
io(po,LED,0)
delay 40
io(po,LED,1)
delay 40
next x
alarm1 = read(alarm1s)
alarm2 = read(alarm2s)
alarm3 = read(alarm3s)
alarm4 = read(alarm4s)
alarm5 = read(alarm5s)
alarm6 = read(alarm6s)
alarm7 = read(alarm7s)
timesetup(tz,DST)
delay 5000
wprint "<br><br>"
curtim = time("hour:min:sec")
wprint "Time Now: "
textbox curtim
wprint "<br><br>"
wprint "Enter alarm times in HH:MM 24 hour format"
wprint "<br>"
wprint |Press "Update All Alarms" button when done|
wprint "<br><br>"
wprint "Alarm 1 "
textbox alarm1
wprint "<br>"
wprint "Alarm 2 "
textbox alarm2
wprint "<br>"
wprint "Alarm 3 "
textbox alarm3
wprint "<br>"
wprint "Alarm 4 "
textbox alarm4
wprint "<br>"
wprint "Alarm 5 "
textbox alarm5
wprint "<br>"
wprint "Alarm 6 "
textbox alarm6
wprint "<br>"
wprint "Alarm 7 "
textbox alarm7
wprint "<br>"
wprint "<br><br>"
button "Update All Alarms", [updatealarms]
button "Test Alarm", [dorelay]
button "End Program", [endprog]
timer 1000, [updatetime]
wait
[updatetime]
curtime = time("hour:min")
if (curtime = alarm1) and (val(time("sec")) = 0) then goto [dorelay]
if (curtime = alarm2) and (val(time("sec")) = 0) then goto [dorelay]
if (curtime = alarm3) and (val(time("sec")) = 0) then goto [dorelay]
if (curtime = alarm4) and (val(time("sec")) = 0) then goto [dorelay]
if (curtime = alarm5) and (val(time("sec")) = 0) then goto [dorelay]
if (curtime = alarm6) and (val(time("sec")) = 0) then goto [dorelay]
if (curtime = alarm7) and (val(time("sec")) = 0) then goto [dorelay]
if (curtime = "01:00") then 'update clock at 1 in the a.m.
timesetup(tz,DST)
delay 5000
endif
if blink = 1 then 'show heartbeat on LED
blink = 0
else
blink = 1
endif
io(po,LED,blink)
wait
[dorelay]
serialprintln "relay sub"
io(po,relay,1)
delay 250
io(po,relay,0)
delay 4000
io(po,relay,1)
delay 250
io(po,relay,0)
wait
[updatealarms]
write(alarm1s,alarm1)
write(alarm2s,alarm2)
write(alarm3s,alarm3)
write(alarm4s,alarm4)
write(alarm5s,alarm5)
write(alarm6s,alarm6)
write(alarm7s,alarm7)
wait
[endprog]
timer 0
end