MistyGro API
C++ API for MistyGro's ESP32 controller based on the Arduino framework
test_timer.cpp
Go to the documentation of this file.
1 // Copyright 2023 Myron Rodrigues
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <WiFi.h>
16 
17 #include "secrets.h"
18 #include "timer.h"
19 
21 
22 void setup()
23 {
24  Serial.begin(115200);
25  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
26 
27  //connect to WiFi
28  Serial.printf("Connecting to %s ", WIFI_SSID);
29  while (WiFi.status() != WL_CONNECTED) {
30  delay(500);
31  Serial.print(".");
32  }
33  Serial.println(" CONNECTED");
34 
35  //init and get the time
36  timer.begin();
37 }
38 
39 void loop()
40 {
41  delay(1000);
43 }
Timer that syncs with NTP server.
Definition: timer.h:27
void begin(long int sync_interval_ms=600000)
initialise the timer, set a sync interval to sync with NTP server
Definition: timer.cpp:52
void print_utc_time()
Print the seconds since epoch.
Definition: timer.cpp:44
void setup()
Definition: test_timer.cpp:22
Timer timer
Definition: test_timer.cpp:20
void loop()
Definition: test_timer.cpp:39