.. _esp8266_quickref: Quick reference for the ESP8266 =============================== .. image:: img/adafruit_products_pinoutstop.jpg :alt: Adafruit Feather HUZZAH board :width: 640px The Adafruit Feather HUZZAH board (image attribution: Adafruit). Below is a quick reference for ESP8266-based boards. If it is your first time working with this board please consider reading the following sections first: .. toctree:: :maxdepth: 1 general.rst tutorial/index.rst Installing MicroPython ---------------------- See the corresponding section of tutorial: :ref:`intro`. It also includes a troubleshooting subsection. General board control --------------------- The MicroPython REPL is on UART0 (GPIO1=TX, GPIO3=RX) at baudrate 115200. Tab-completion is useful to find out what methods an object has. Paste mode (ctrl-E) is useful to paste a large slab of Python code into the REPL. The :mod:`machine` module:: import machine machine.freq() # get the current frequency of the CPU machine.freq(160000000) # set the CPU frequency to 160 MHz The :mod:`esp` module:: import esp esp.osdebug(None) # turn off vendor O/S debugging messages esp.osdebug(0) # redirect vendor O/S debugging messages to UART(0) Networking ---------- The :mod:`network` module:: import network wlan = network.WLAN(network.STA_IF) # create station interface wlan.active(True) # activate the interface wlan.scan() # scan for access points wlan.isconnected() # check if the station is connected to an AP wlan.connect('ssid', 'key') # connect to an AP wlan.config('mac') # get the interface's MAC address wlan.ifconfig() # get the interface's IP/netmask/gw/DNS addresses ap = network.WLAN(network.AP_IF) # create access-point interface ap.active(True) # activate the interface ap.config(ssid='ESP-AP') # set the SSID of the access point A useful function for connecting to your local WiFi network is:: def do_connect(): import network wlan = network.WLAN(network.STA_IF) wlan.active(True) if not wlan.isconnected(): print('connecting to network...') wlan.connect('ssid', 'key') while not wlan.isconnected(): pass print('network config:', wlan.ifconfig()) Once the network is established the :mod:`socket ` module can be used to create and use TCP/UDP sockets as usual. Delay and timing ---------------- Use the :mod:`time