Open-source weather station for astronomy
at main 936 B view raw
1import wifimgr 2import network 3import time 4import machine 5 6try: 7 import usocket as socket 8except: 9 import socket 10 11# WiFi parameters 12# ssid = 'YOUR-SSID' 13# password = 'YOUR-PASSWORD' 14 15# Define ESP32 name 16wlan = network.WLAN(network.STA_IF) 17wlan.active(True) 18wlan.config(dhcp_hostname = 'AstroWeatherStation') 19 20# Comment to use standard WiFi connection 21wlan = wifimgr.get_connection() 22 23# Uncomment to use standard WiFi connection 24# wlan.connect(ssid, password) 25# t0 = time.time() 26# while not wlan.isconnected(): 27# print('.', end = " ") 28# time.sleep_ms(100) 29# if time.time()-t0 > 10: 30# machine.reset() 31 32if wlan is None: 33 print("Could not initialize the network connection.") 34 while True: 35 pass 36 37# Main Code goes here, wlan is a working network.WLAN(STA_IF) instance. 38print("Connection successful") 39print('dhcp_hostname: {}'.format(wlan.config('dhcp_hostname'))) 40print('network config: ', wlan.ifconfig())