Skip to content

Commit 620c813

Browse files
committed
Bugfix microsecs
1 parent 7d9b766 commit 620c813

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arduino-modbus-rtu-tcp-gateway/arduino-modbus-rtu-tcp-gateway.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const byte SCAN_FUNCTION_FIRST = 0x03; // Function code sent durin
5757
const byte SCAN_FUNCTION_SECOND = 0x04; // Function code sent during Modbus RTU Scan request (second attempt)
5858
const byte SCAN_DATA_ADDRESS = 0x01; // Data address sent during Modbus RTU Scan request (both attempts)
5959
const int FETCH_INTERVAL = 2000; // Fetch API interval (ms) for the Modbus Status webpage to renew data from JSON served by Arduino
60-
const unsigned int STATS_EEPROM_INTERVAL = 60; // Interval (minutes) for saving Modbus statistics to EEPROM (in order to minimize writes to EEPROM)
60+
const unsigned long STATS_EEPROM_INTERVAL = 60; // Interval (minutes) for saving Modbus statistics to EEPROM (in order to minimize writes to EEPROM)
6161
const byte MAX_RESPONSE_LEN = 16; // Max length (bytes) of the Modbus response shown in WebUI
6262
// List of baud rates (divided by 100) available in WebUI. Feel free to add your custom baud rate (anything between 3 and 2500)
6363
const unsigned int BAUD_RATES[] = { 3, 6, 9, 12, 24, 48, 96, 192, 384, 576, 1152 };
@@ -307,8 +307,8 @@ void loop() {
307307

308308
manageSockets();
309309

310-
if (statsEepromTimer.isOver()) {
311-
statsEepromTimer.sleep(STATS_EEPROM_INTERVAL * 60 * 1000);
310+
if (statsEepromTimer.isOver() == true) {
311+
statsEepromTimer.sleep(STATS_EEPROM_INTERVAL * 60UL * 1000UL * 1000UL); // STATS_EEPROM_INTERVAL is in minutes, sleep is in microsecs!
312312
EEPROM.put(CONFIG_START + 1 + sizeof(localConfig), errorCount);
313313
}
314314

0 commit comments

Comments
 (0)