Example Code for MicroPython-WiFi Connection

This example verifies if the ESP32-C6 wireless communication module of the development board is functional. The sample program demonstrates connecting to a WiFi hotspot via the ESP32-C6.

Hardware Preparation

Software Preparation

Sample Code

import network, time
def connect():
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    if not wlan.isconnected():
        print('ESP32-P4 is connecting to WiFi', end="")
        wlan.connect('SSID', 'PWD')  # Replace 'SSID' with your WiFi name and 'PWD' with your WiFi password
        while not wlan.isconnected():
            print(".", end="")
            time.sleep(1)
    print('\nNetwork information: ', wlan.ifconfig())  

connect()

Was this article helpful?

TOP