summary

In an environment where the device can directly use the network, time information can be obtained using the provided NTP library.

For information NTP(Network Time Protocol), see the Wiki page: Network Time Protocol

In this article, will sumarize that assuming a device that cannot be directly connected to the network, the contents of receiving time information from an NTP server using an S2E (Serial to ethernet) device.

The S2E device is a Serial to Ethernet device, and as the name suggests, it is a device that converts data between serial and Ethernet.

The test configuration is simple.

When request data is transmitted through the serial interface, the packet is converted to Ethernet and transmitted to the configured Remote Host (in this case, an NTP server).

(diagram will be updated)

I used WIZnet’s product that combination of WIZ750SR-TTL and EVB.

WIZ750SR is an S2E product equipped with W7500P MCU and is designed in the form of a pin header and RJ-45 connector.

More details can be found at the link below.

Materials

  • WIZ750SR-TTL with EVB
  • Ethernet cable
  • USB to RS-232 cable
  • Micro 5 pin USB cable
    • Supply power and monitor debug messages

WIZ750SR Settings

WIZnet supports a GUI-based Configuration Tool (hereafter Config Tool) that can configure WIZ750SR products.

Setting through Serial Command mode is also supported, so you can proceed with the method that suits you.

First, using the Config tool, the operation mode and connection information was set as shown below.

  • Remote host / port
    • Remote host: pool.ntp.org
    • Remote port: 123
  • Operation mode: UDP
  • Local port: 123

After inputting the setting value and pressing the Setting button at the top, the device setting is changed and saved, and the device is automatically reset.

If a pop-up appears with the message Device configuration complete, the setting is successful.

If the setting is not successful , refer to the FAQ page of the Config Tool.

Check for debug messages (optional)

You can monitor the operation status through the debug port.

If you are using EVB, an FTDI chip is included, so you can power on and check debug messages when connected via a Micor 5pin USB cable.

Python Code

The part that converts data sending and receiving data with the serial interface of WIZ750SR uses Python code.

The NTP related code was referred to in the link below, and the socket communication part in the original code was used by changing it to serial communication.

The recognized COM port may be different, so check it in Device Manager before proceeding.

Install packages

Install the pyserial package to transfer data over serial.

pip install pyserial

(or)
python -m pip install pyserial

Execution

python requestTimefromNtp.py 

This is an example code that receives time information from NTP server, gets Timestamp value, and %Y-%m-%d %H:%M:%S outputs it in the form.

If the current time is output, the time information is well retrieved.

Reference

https://stackoverflow.com/a/56613595/8515109