Bootstrap

esp32S3 http通信

esp32 进行http通信非常简单,用到的库有urequests、network。urequests用于发送http请求并获取返回结果;network用于连接网络

network连接网络代码如下

import network
def do_connect():
    """链接WIFI"""
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    if not wlan.isconnected():
        print('connecting to network...')
        wlan.connect('yuxuan', 'yuxuan893888')
        i = 1
        while not wlan.isconnected():
            print("正在链接...{}".format(i))
            i += 1
            time.sleep(1)
    print('network config:', wlan.ifconfig())
 
 
# 联网
do_connect()

urequests发送请求代码如下

import urequests

url = 'http://192.168.100.197:8080/test'
data = '{"name": "value&#
;