Skip to content

Commit

Permalink
Merge pull request #678 from pimoroni/patch-cosmic-example
Browse files Browse the repository at this point in the history
Patch: fixed error caused by missing secrets.py
  • Loading branch information
Gadgetoid authored Feb 22, 2023
2 parents 8c4e54a + e3dc655 commit b08cf1f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions micropython/examples/cosmic_unicorn/launch/today.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@

DAYS = ["Mon", "Tue", "Wed", "Thur", "Fri", "Sat", "Sun"]

# Enable the Wireless
wlan = network.WLAN(network.STA_IF)
wlan.active(True)


def network_connect(SSID, PSK):
# Enable the Wireless
wlan = network.WLAN(network.STA_IF)
wlan.active(True)

# Number of attempts to make before timeout
max_wait = 5
Expand All @@ -52,12 +53,16 @@ def network_connect(SSID, PSK):
# Function to sync the Pico RTC using NTP
def sync_time():

network_connect(WIFI_SSID, WIFI_PASSWORD)

try:
ntptime.settime()
except OSError:
print("Unable to sync with NTP server. Check network and try again.")
network_connect(WIFI_SSID, WIFI_PASSWORD)
except NameError:
print("Create secrets.py with your WiFi credentials")

if wlan.status() < 0 or wlan.status() >= 3:
try:
ntptime.settime()
except OSError:
print("Unable to sync with NTP server. Check network and try again.")


def init():
Expand Down

0 comments on commit b08cf1f

Please sign in to comment.