File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
2+ # SPDX-FileCopyrightText: 2024 anecdata for Adafruit Industries
3+ #
4+ # SPDX-License-Identifier: Unlicense
5+
6+ """Print out time based on NTP, using connection manager"""
7+
8+ import adafruit_connection_manager
9+ import adafruit_ntp
10+
11+ # determine which radio is available
12+ try :
13+ import wifi
14+ import os
15+
16+ # adjust method to get credentials as necessary...
17+ wifi_ssid = os .getenv ("CIRCUITPY_WIFI_SSID" )
18+ wifi_password = os .getenv ("CIRCUITPY_WIFI_PASSWORD" )
19+ radio = wifi .radio
20+ while not radio .connected :
21+ radio .connect (wifi_ssid , wifi_password )
22+ except ImportError :
23+ import board
24+ from digitalio import DigitalInOut
25+ from adafruit_wiznet5k .adafruit_wiznet5k import WIZNET5K
26+
27+ # adjust with busio.SPI() as necessary...
28+ spi = board .SPI ()
29+ # adjust pin for the specific board...
30+ eth_cs = DigitalInOut (board .D10 )
31+ radio = WIZNET5K (spi , eth_cs )
32+
33+ # get the socket pool from connection manager
34+ socket = adafruit_connection_manager .get_radio_socketpool (radio )
35+
36+ # adjust tz_offset for locale...
37+ ntp = adafruit_ntp .NTP (socket , tz_offset = - 5 )
38+
39+ print (ntp .datetime )
You can’t perform that action at this time.
0 commit comments