本站改版新增arduino频道

Micropython
Arduino

micropython boot.py 联网模板


# config.py


app_config = {

    'camera': 'M5CAMERA',  # camera -> 'ESP32-CAM' or 'M5CAMERA'

    'led': 14, # led -> 4: ESP32-CAM or 14: M5CAMERA

}


wifi_config = {

    'ssid':'NBWIFI',

    'password':'z7758521'

}






# boot.py

import config

import network

import utime

import ntptime


def do_connect():

    sta_if = network.WLAN(network.STA_IF)

    start = utime.time()

    timed_out = False


    if not sta_if.isconnected():

        print('connecting to network...')

        sta_if.active(True)

        sta_if.connect(config.wifi_config["ssid"], config.wifi_config["password"])

        while not sta_if.isconnected() and \

            not timed_out:        

            if utime.time() - start >= 20:

                timed_out = True

            else:

                pass


    if sta_if.isconnected():

        ntptime.settime()

        print('network config:', sta_if.ifconfig())

    else: 

        print('internet not available')


do_connect()



推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号

执行时间: 0.0096769332885742 seconds