Skip to content

Commit

Permalink
Configurable NTP server
Browse files Browse the repository at this point in the history
NTP update every hour
Fixes #22
  • Loading branch information
jantenhove committed Jul 17, 2019
1 parent 4fb44de commit 2ca6fce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion GoodWeLogger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GoodWeCommunicator goodweComms(&settingsManager, false);
MQTTPublisher mqqtPublisher(&settingsManager, &goodweComms, false);
PVOutputPublisher pvoutputPublisher(&settingsManager, &goodweComms, false);
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org");
NTPClient timeClient(ntpUDP, NTP_SERVER);
bool validTimeSet =false;
int reconnectCounter = 0;

Expand Down Expand Up @@ -58,6 +58,7 @@ void setup()
Serial.println("");
Serial.println("Connected!");

timeClient.setUpdateInterval(1000 * 60 * 60); //one hour updates
timeClient.begin();

ArduinoOTA.setHostname("GoodWeLogger");
Expand Down
2 changes: 1 addition & 1 deletion MQTTPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void MQTTPublisher::handle()
}
}
else if (sendRegular) //only send offline info on regular basis
if (sendOk) sendOk = publishOnMQTT(prependTopic, "/online", "0");
if (sendOk) sendOk = publishOnMQTT(prependTopic, "/online", "0");
}

//On the github page of the pubsubclient it was suggested to add extra client.loop().
Expand Down
8 changes: 7 additions & 1 deletion Settings.example.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@
#define RS485_RX D1

//rs485 transmit pin
#define RS485_TX D2
#define RS485_TX D2

//Hostname to use on local network
#define WIFI_HOSTNAME "GoodWeLogger"

//NTP server addres
#define NTP_SERVER "pool.ntp.org"

0 comments on commit 2ca6fce

Please sign in to comment.