数码营电子:基于微型控制器的编程、电路设计与电子产品制做。邮箱:shumaying@hotmail.com

ESP8266

From 数模电子制做
Jump to navigation Jump to search
 Technical Documents:
  1. File:Esp8266-technical reference(en).pdf
  2. File:Esp8266-sdk getting started guide en.pdf
sudo apt-get install gcc git wget make libncurses-dev flex bison gperf python python-serial

sudo apt-get install libncurses5-dev libncursesw5-dev
~$ sudo apt-get update && sudo apt-get upgrade
~$ sudo apt-get -y install gperf

~$ pip install pyserial
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
    
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
    
    See /usr/share/doc/python3.12/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.


ESP8266 WiFi Module[edit]

Nodemcu[edit]

AP & STA Mode[edit]

Tutorials[edit]

Esp8266-WeMos-pins.jpg

AT Update firmware[edit]

Forum[edit]

SDK[edit]

Tools[edit]

pins[edit]

Documents[edit]

Example[edit]

Others[edit]

MySQL[edit]

Tool[edit]

Web server[edit]

SPIFFS[edit]

Serial[edit]

Serial object works much the same way as on a regular Arduino. Apart from hardware FIFO (128 bytes for TX and RX) HardwareSerial has additional 256-byte TX and RX buffers. Both transmit and receive is interrupt-driven. Write and read functions only block the sketch execution when the respective FIFO/buffers are full/empty.

Serial uses UART0, which is mapped to pins GPIO1 (TX) and GPIO3 (RX). Serial may be remapped to GPIO15 (TX) and GPIO13 (RX) by calling Serial.swap() after Serial.begin. Calling swap again maps UART0 back to GPIO1 and GPIO3.

Serial1 uses UART1, TX pin is GPIO2. UART1 can not be used to receive data because normally it's RX pin is occupied for flash chip connection. To use Serial1, call Serial1.begin(baudrate).

By default the diagnostic output from WiFi libraries is disabled when you call Serial.begin. To enable debug output again, call Serial.setDebugOutput(true). To redirect debug output to Serial1 instead, call Serial1.setDebugOutput(true).

You also need to use Serial.setDebugOutput(true) to enable output from printf() function.

Both Serial and Serial1 objects support 5, 6, 7, 8 data bits, odd (O), even (E), and no (N) parity, and 1 or 2 stop bits. To set the desired mode, call Serial.begin(baudrate, SERIAL_8N1), Serial.begin(baudrate, SERIAL_6E2), etc.

two ESP8266 via WiFi[edit]

servo[edit]

UDP[edit]

communication test tool[edit]

Raspberry pi & Node-RED Dashboard[edit]

MQTT Broker[edit]

Qrcode for gh a3b9e9962ce8 1280.jpg