pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

Atomic Base

UIFlow 1.0 Project

Network

Example

Example 1

Set the Wi-Fi name and password, connect to Wi-Fi, and print the connection result to the serial monitor.

from m5stack import *
from m5stack_ui import *
from uiflow import *
import wifiCfg

wifiCfg.doConnect('M5-R&D', '**********')
print(wifiCfg.wlan_sta.isconnected())

Example 2

Download the Esptouch app on your phone, upload the program to the M5 device, and enter the Wi-Fi password in the Esptouch app. If the serial monitor shows a successful connection and displays the IP address, the device has successfully connected to Wi-Fi and will automatically connect to this Wi-Fi in the future.

  1. After uploading the program to the M5 device, enter the Wi-Fi password in the Esptouch app and click confirm.
schematics
  1. After completion, the device automatically connects to Wi-Fi and outputs the IP address.
schematics

API

wifiCfg.autoConnect(lcdShow=False)
  • Attempts to automatically connect to a previously configured Wi-Fi network.
wifiCfg.autoConnect(lcdShow=True)
  • Attempts to automatically connect to a previously configured Wi-Fi network and displays the connection status on the LCD.
wifiCfg.reconnect()
  • Attempts to reconnect to a previously configured and saved Wi-Fi network. This method is typically used to retry a connection after the device loses connection.
wifiCfg.doConnect('', '')
  • Sets the Wi-Fi name (SSID) and password.
M5Label('label0', x=193, y=67, color=0x000, font=FONT_MONT_14, parent=None)
  • Represents sending a point-to-point message to a specified API Key.
str(getP2PData())
  • Retrieves received P2P (point-to-point) message data.
network.WLAN(network.STA_IF)
  • Creates a WLAN (Wireless Local Area Network) interface object. Choose the Wi-Fi mode:
    • Station mode: Connect to a local area Wi-Fi network.
    • Access point mode: Create your own Wi-Fi hotspot.
wlan.config(essid='', password='', authmode=network.AUTH_OPEN)
  • Configures the WLAN interface parameters.
    • essid: Sets the access point's SSID (network name).
    • password: Sets the access point's password.
    • authmode: Sets the access point's authentication mode.
wlan.active(True)
  • Activates the interface: This command is used to enable the device's Wi-Fi functionality, allowing it to begin wireless communication.
str(wlan.scan())
  • Scans for nearby Wi-Fi networks and returns a list containing available network information.
str(wlan.isconnected())
  • Checks if the ESP32 is connected to a Wi-Fi network.
wlan.connect('your_SSID', 'your_PASSWORD')
  • ssid: The name of the Wi-Fi network to connect to.
  • password: The password for the Wi-Fi network.
str(wlan.config('mac'))
  • Retrieves the device's MAC address and converts it to a string format.
  • Retrieves the currently configured SSID (network name) and converts it to a string format.
str(wlan.ifconfig())
  • Retrieves the device's network configuration.
str(wlan.status())
  • Retrieves the current Wi-Fi connection status.
wlan.disconnect()
  • Disconnects from the Wi-Fi network.
str(1001)
  • STAT_IDLE: Wi-Fi idle status. The device is not currently attempting to connect to any Wi-Fi network.
  • STAT_CONNECTING: Wi-Fi connecting status. The device is attempting to connect to the specified Wi-Fi network.
  • STAT_GOT_IP: Wi-Fi connected and obtained an IP address. The device has successfully connected to the Wi-Fi network and received an IP address from the DHCP server.
smartconfig.set_type(smartconfig.ESPTOUCH)
  • ESPTOUCH: Uses the ESPTOUCH protocol for configuration. The Wi-Fi configuration information (SSID and password) is sent to the device via a mobile app, allowing it to connect to the specified Wi-Fi network.

  • AIRKISS: Uses the AIRKISS protocol for configuration. AIRKISS is a wireless configuration protocol developed by Tencent, used to send Wi-Fi configuration information to the device.

  • ESPTOUCH_AIRKISS: Uses both ESPTOUCH and AIRKISS protocols simultaneously for configuration. The device will listen to both protocols, and the mobile app can use either protocol to send Wi-Fi configuration information. The device will configure itself after receiving the information.

smartconfig.start()
  • Starts the SmartConfig feature, putting the device into SmartConfig configuration mode, and waits to receive Wi-Fi configuration information (SSID and password) from the mobile app.
smartconfig.stop()
  • Stops the SmartConfig feature and exits SmartConfig configuration mode.
str(smartconfig.status())
  • Retrieves the current status of SmartConfig.
str(smartconfig.get_ssid())
  • Retrieves the SSID (network name) received during the SmartConfig process.
str(smartconfig.get_password())
  • Retrieves the password received during the SmartConfig process.
str(smartconfig.get_phoneip())
  • Retrieves the phone's IP address during the SmartConfig process.
str(smartconfig.get_phoneip())
  • Represents the event when SmartConfig completes scanning for Wi-Fi networks.
On This Page