README - Update install section (WiFi config) (#4)

This commit is contained in:
iGoX 2024-12-23 15:57:19 +01:00
parent 47f63db85f
commit 086a4de44a
2 changed files with 10 additions and 6 deletions

View file

@ -1,21 +1,20 @@
# This file is executed on every boot (including wake-boot from deepsleep)
# It is executed after boot.py, before main.py
# It is executed before main.py
import os, machine
import network
import gc
gc.collect()
# Disable Access Point
ap_if = network.WLAN(network.AP_IF)
ap_if.active(False)
# Connect to the WIFI when booting
# --- WIFI Configuration ---
SSID = '<YOUR WIFI SSID>' # Set the WIFI network SSID
PASSWORD = '<YOUR WIFI PASSWORD>' # Set the WIFI network password
network.country('<YOUR COUNTRY CODE>') # Set the country code for the WIFI (ISO 3166-1 Alpha-2 country code)
network.hostname('busylight-esp32') # Hostname that will identify this device on the network
# --------------------------
# Function to connect to the WIFI
def boot_wifi_connect():
wlan = network.WLAN(network.STA_IF)
if not wlan.isconnected():
@ -25,10 +24,13 @@ def boot_wifi_connect():
while not wlan.isconnected():
pass
ip, mask, gateway, dns = wlan.ifconfig()
# Print the network configuration
print('\nNetwork config:')
print('- IP address: ' + ip)
print('- Network mask: ' + mask)
print('- Network gateway: ' + gateway)
print('- DNS server: ' + dns + '\n')
# Connect to the WIFI when booting
boot_wifi_connect()