circuitpython/tests/circuitpython-manual/socketpool/datagram
microDev a52eb88031
run code formatting script
2021-03-15 19:27:36 +05:30
..
ntp.py run code formatting script 2021-03-15 19:27:36 +05:30
readme.md Move manual tests and rename 2021-02-17 11:43:45 -05:00

readme.md

Circuitpython Datagrams

This example demonstrates using UDP (datagrams) with the Socket module, accessing the time from an NTP server using sendto and recvfrom_into.

Prerequisites

Circuitpython V6.2.0 minimum.

Expected behavior

The Circuitpython device will attempt to connect to wifi, and send a request for the time to pool.ntp.org. It will then convert the seconds returned into a unix time struct.

Expected output:

Sending packet
Received packet
Address: ('82.197.188.130', 31488)
Time: struct_time(tm_year=2021, tm_mon=2, tm_mday=11, tm_hour=22, tm_min=22, tm_sec=40, tm_wday=3, tm_yday=42, tm_isdst=-1)