#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
Sub Process_Globals
Public Serial1 As Serial
Private wifi As ESP8266WiFi
Private DT(8) As Byte
Private rtc As ESP8266rtc
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
If wifi.Connect2("your ssid","your password") Then 'change to your network SSID (use Connect2 if a password is required).
Log("Connected to wireless network.")
rtc.Initialize("rtc_Alarm",True)
'I have provided my own "url.php" as an example only.
'you must create your own as per the details in the post for v1-04
err = rtc.GetUTC(DT,"www.starchild.com.au","/utc.php"))
If err <> 0 Then
Log("GetUTC failed: ",err)
End If
rtc.SetClock(DT,8,0) 'offset for Western Australia. UTC +08:00
Log(rtc.ReadClock(DT))
Log("RTC: ",DT(0),",",DT(1),",",DT(2),",",DT(3),",",DT(4),",",DT(5),",",DT(6),",",DT(7))
rtc.SetAlarm(1,rtc.Sec2DT(rtc.DT2Sec(DT)+10))
rtc.SetAlarm(2,rtc.Sec2DT(rtc.DT2Sec(DT)+5))
rtc.SetAlarm(3,rtc.Sec2DT(rtc.DT2Sec(DT)+15))
rtc.SetAlarm(9,rtc.Sec2DT(rtc.DT2Sec(DT+rtc.SECONDS_1MINUTE))
rtc.SetAlarm(5,rtc.ThisTime(6,30,0)) 'set alarm for 6:30am (within the next 24hrs)
Else
Log("Failed to connect.")
End If
End Sub
private Sub rtc_Alarm(index As Byte)
If index=0 Then
'tick every second
rtc.ReadClock(DT)
Log("RTC: ",rtc.ShortDOW(DT),", ",rtc.ShortDate(DT),", ",rtc.Time24(DT))
Return
End If
Log("AlarmEvent: ",index)
End Sub