assign the static IP so it don't change and we can access web page for it.
This commit is contained in:
parent
3dd565537f
commit
121bb31f6e
16
main.py
16
main.py
@ -28,8 +28,18 @@ from scripts.web_server import TempWebServer
|
|||||||
# Connect to WiFi
|
# Connect to WiFi
|
||||||
wifi = connect_wifi(led)
|
wifi = connect_wifi(led)
|
||||||
|
|
||||||
# Print WiFi details
|
# Set static IP and print WiFi details
|
||||||
if wifi and wifi.isconnected():
|
if wifi and wifi.isconnected():
|
||||||
|
# Configure static IP
|
||||||
|
static_ip = '192.168.86.43' # Your desired static IP
|
||||||
|
subnet = '255.255.255.0' # Subnet mask (usually this)
|
||||||
|
gateway = '192.168.86.1' # Your router's IP
|
||||||
|
dns = '192.168.86.1' # DNS server (usually same as gateway)
|
||||||
|
|
||||||
|
wifi.ifconfig((static_ip, subnet, gateway, dns))
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# Print WiFi details
|
||||||
ifconfig = wifi.ifconfig()
|
ifconfig = wifi.ifconfig()
|
||||||
print("\n" + "="*50)
|
print("\n" + "="*50)
|
||||||
print("WiFi Connected Successfully!")
|
print("WiFi Connected Successfully!")
|
||||||
@ -41,8 +51,8 @@ if wifi and wifi.isconnected():
|
|||||||
print(f"Web Interface: http://{ifconfig[0]}")
|
print(f"Web Interface: http://{ifconfig[0]}")
|
||||||
print("="*50 + "\n")
|
print("="*50 + "\n")
|
||||||
|
|
||||||
# Send startup message
|
# Send startup message with IP
|
||||||
send_discord_message("Pico W online and connected ✅")
|
send_discord_message(f"Pico W online at http://{ifconfig[0]} ✅")
|
||||||
else:
|
else:
|
||||||
print("\n" + "="*50)
|
print("\n" + "="*50)
|
||||||
print("WiFi Connection Failed!")
|
print("WiFi Connection Failed!")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user