nodeMCU_esp8266管脚示意图/特殊管脚的使用避坑(D3/D4/D8/..)

reference material

通讯

NodeMCU is an open-source Lua based firmware and development board specially targeted for IoT based Applications. It includes firmware that runs on the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on the ESP-12 module.

NodeMCU Development Board Pinout Configuration

Pin CategoryNameDescription
PowerMicro-USB, 3.3V, GND, VinMicro-USB: NodeMCU can be powered through the USB port 3.3V: Regulated 3.3V can be supplied to this pin to power the board GND: Ground pins Vin: External Power Supply
Control PinsEN, RSTThe pin and the button resets the microcontroller
Analog PinA0Used to measure analog voltage in the range of 0-3.3V
GPIO PinsGPIO1 to GPIO16NodeMCU has 16 general purpose input-output pins on its board
SPI PinsSD1, CMD, SD0, CLKNodeMCU has four pins available for SPI communication.
UART PinsTXD0, RXD0, TXD2, RXD2NodeMCU has two UART interfaces, UART0 (RXD0 & TXD0) and UART1 (RXD1 & TXD1). UART1 is used to upload the firmware/program.
I2C PinsNodeMCU has I2C functionality support but due to the internal functionality of these pins, you have to find which pin is I2C.

特殊引脚情况说明🤣🤷‍♂️

建议查阅NodeMCU datasheet
Best Pins to Use – ESP8266
  • One important thing to notice about ESP8266 is that the GPIO number doesn’t match the label on the board silkscreen. For example, D0 corresponds to GPIO16 and D1 corresponds to GPIO5.

  • The following table shows the correspondence between the labels on the silkscreen and the GPIO number as well as what pins are the best to use in your projects, and which ones you need to be cautious.

  • The pins highlighted in green are OK to use. The ones highlighted in yellow are OK to use, but you need to pay attention because they may have unexpected behavior mainly at boot. The pins highlighted in red are not recommended to use as inputs or outputs.
    在这里插入图片描述

  • 了解这些特殊引脚是必要的,笔者在使用nodeMCU时就曾被坑惨了
GPIO0(D3)
  • GPIO0(D3)引脚在开发板运行中需要一直保持高电平状态。
  • 否则ESP8266将进入程序上传工作模式也就无法正常工作了。

您无需对GPIO0引脚进行额外操作,因为NodeMCU的内置电路可以确保GPIO0引脚在工作时连接高电平而在上传程序时连接低电平。

GPIO2(D4)
  • GPIO2(D4)引脚在NodeMCU开发板启动时是不能连接低电平的。
    • 实际使用过程中,D4电平不向其他管脚可以被拉低到和GND一样低,也就是说,该引脚不太推荐使用,容易掉坑;
    • 在这里插入图片描述
GPIO15(D8)
  • GPIO15(D8)引脚在开发板运行中一直保持低电平状态。

因此请不要使用GPIO15引脚来读取开关状态或进行I²C通讯。

  • 上拉电阻/下拉电阻
    GPIO 0-15引脚都配有内置上拉电阻。这一点与Arduino十分类似。GPIO16 引脚配有内置下拉电阻。
Esp8266芯片的模拟输入
  • ESP8266 只有一个模拟输入引脚(该引脚通过模拟-数字转换将引脚上的模拟电压数值转化为数字量)。
  • 此引脚可以读取的模拟电压值为 0 – 1.0V。请注意:ESP8266 芯片模拟输入引脚连接在1.0V以上电压可能损坏ESP8266芯片。

以上所描述的是针对ESP8266芯片的引脚。

  • 幸运的是,对于NodeMCU开发板引脚,情况就不同了。
    NodeMCU开发板配有降压电路。您可以用NodeMCU开发板的模拟输入引脚读取0-3.3V的模拟电压信号。

串行端口

ESP8266有2个硬件串行端口(UART)。

串行端口0(UART0)使用GPIO1和GPIO3引脚。其中GPIO1引脚是TX0,GPIO3是RX0。

串行端口1(UART1)使用GPIO2和GPIO8引脚。其中GPIO2引脚是TX1,GPIO8是RX1。请注意,由于GPIO8被用于连接闪存芯片,串行端口1只能使用GPIO2来向外发送串行数据。

I²C

ESP8266只有软件模拟的I²C端口,没有硬件I²C端口。也就是说我们可以使用任意的两个GPIO引脚通过软件模拟来实现I²C通讯。ESP8266的数据表(datasheet)中,GPIO2标注为SDA,GPIO14标注为SCL。

SPI

ESP8266的SPI端口情况如下:

GPIO14 — CLK
GPIO12 — MISO
GPIO13 — MOSI
GPIO 15 — CS(SS)

ESP8266引脚功能一览

GPIO功能状态限制
0引导模式选择3.3V无Hi-Z
1TX0串口通讯过程中不能使用
2引导模式选择 TX13.3V启动时不能接地 启动时发送调试信息
3RX0串口通讯过程中不能使用
4SDA (I²C)
5SCL (I²C)
6 – 11连接闪存x不可用
12MISO (SPI)
13MOSI (SPI)
14SCK (SPI)
15SS (SPI)0V上拉电阻不可用
16睡眠唤醒无上拉电阻,仅有下拉电阻 连接 RST 引脚实现睡眠唤醒

来自谷歌图片

在这里插入图片描述
SD系列的不建议使用
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

  • 15
    点赞
  • 114
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值