-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.ino
More file actions
27 lines (21 loc) · 785 Bytes
/
loop.ino
File metadata and controls
27 lines (21 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
void loop ()
{
// Add support for OTA***************************************
ArduinoOTA.handle();
// **********************************************************
//MQTT processing
if (!MQTTclient.connected()) // Note that MQTTclient.connected() will still return 'true' until the MQTT keepalive timeout has expired (around 35 seconds for my setup)
{
MQTT_Connect();
//any other code which runs regardless of mqtt connection here
}
MQTTclient.loop(); //call this frequently
//Manage heartbeat function timing
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > interval)
{
previousMillis = currentMillis;
heartbeat();
}
//any other code which only runs when mqtt connected here:
}