LAN Communications

1. Configure the LAN Server

This project requires the Server and the main control board to work in the same local area network. The principle: Setup one PC as a server, connect the main control board to the Server through the local area network, and then PC and board communicate through a fixed port. First, download and install the network debugging assistant (Net Assistant network debugging assistant software in this project). If the installation is successful, open the software, select "TCP Server" in the upper left corner to set the "Protocol", and then set the "Local host addr" and "Local host port" below. If all were done, click "Open" to enter the Server.


2. Debug MicroPython program

Enter the following code into the code editor:

import network
import usocket
from machine import Pin, I2C, ADC, UART, SPI, PWM
from time import sleep

N1 = network.WLAN_UART(network.STA_IF)

print("API list:")

print("wifi list:")
lis = N1.scan()
for q in lis:

if N1.isconnected():
    print("    ip               gateway           netmask            MAC            ssid")
    s.send('Hello! Wio RP2040')
Please fill in line 17 (the name and password of the WiFi ) and line 22(the IP address and port number of the computer server). Then run the program, you should see the message sent by the main control board in the Data log of the network debugging assistant.


If you want to run other codes after running a program with network functions, please click the "RUN" button on the main control board to restart. After restarting, the main control board can run other programs.