I have an Arduino Mega 2560 with an ethernet shield (w5100) connected to a local database. My end goal is to send date time stamps whenever an input is detected, but for the sake of testing I’m sending data every 5 seconds. Attached is my code. “testWorks.ino” successfully sends a date time stamp to my local database, but once I implement NTP time synchronization (“testSimple.ino”), the Arduino stops connecting after 4 times. By this, I mean “Connection Established” prints to the serial monitor 4 times (goes through the loop block 4 times), and the database successfully receives the data. But it stops working after the 4th time, printing “Connection failed.” Does the 4th time have anything to do with max sockets equaling 4 in the Ethernet library?
Because “testWorks.ino” works, but “testSimple.ino” doe not work, I know there must be an issue with the NTP synchronization code, but I am new to all this and any help/suggestions will be appreciated. Thank you for your time.
testWorks.ino (1.55 KB)
testSimple.ino (4.95 KB)