ESP8266 Pinout

 



from https://github.com/esp8266/Arduino/blob/2.5.2/variants/d1_mini/pins_arduino.h#L37-L45

static const uint8_t D0   = 16;

static const uint8_t D1   = 5;

static const uint8_t D2   = 4;

static const uint8_t D3   = 0;

static const uint8_t D4   = 2;

static const uint8_t D5   = 14;

static const uint8_t D6   = 12;

static const uint8_t D7   = 13;

static const uint8_t D8   = 15;

static const uint8_t RX   = 3;

static const uint8_t TX   = 1;



from https://randomnerdtutorials.com/esp8266-pinout-reference-gpios/

ESP8266-01 Pinout

If you’re using an ESP8266-01 board, you can use the following GPIO diagram as a reference.

ESP-01 ESP8266 pinout diagram gpios pins

ESP8266 12-E NodeMCU Kit

The ESP8266 12-E NodeMCU kit pinout diagram is shown below.

ESP8266 12-E NodeMCU Kit pinout diagram gpios pinsWemos D1 Mini Pinout

The following figure shows the WeMos D1 Mini pinout.

WeMos D1 Mini Pinout diagram gpios pins

Download PDF with ESP8266 Pinout Diagrams

We’ve put together a handy PDF that you can download and print, so you always have the ESP8266 diagrams next to you:

Download PDF Pinout Diagrams »

ESP8266 Peripherals

The ESP8266 peripherals include:

  • 17 GPIOs
  • SPI
  • I2C (implemented on software)
  • I2S interfaces with DMA
  • UART
  • 10-bit ADCBest 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.

LabelGPIOInputOutputNotes
D0GPIO16no interruptno PWM or I2C supportHIGH at boot
used to wake up from deep sleep
D1GPIO5OKOKoften used as SCL (I2C)
D2GPIO4OKOKoften used as SDA (I2C)
D3GPIO0pulled upOKconnected to FLASH button, boot fails if pulled LOW
D4GPIO2pulled upOKHIGH at boot
connected to on-board LED, boot fails if pulled LOW
D5GPIO14OKOKSPI (SCLK)
D6GPIO12OKOKSPI (MISO)
D7GPIO13OKOKSPI (MOSI)
D8GPIO15pulled to GNDOKSPI (CS)
Boot fails if pulled HIGH
RXGPIO3OKRX pinHIGH at boot
TXGPIO1TX pinOKHIGH at boot
debug output at boot, boot fails if pulled LOW
A0ADC0Analog InputX

Continue reading for a more detailled and in-depth analysis of the ESP8266 GPIOs and its functions.

GPIOs connected to the Flash Chip

GPIO6 to GPIO11 are usually connected to the flash chip in ESP8266 boards. So, these pins are not recommended to use.

Pins used during Boot

The ESP8266 can be prevented from booting if some pins are pulled LOW or HIGH. The following list shows the state of the following pins on BOOT:

  • GPIO16: pin is high at BOOT
  • GPIO0: boot failure if pulled LOW
  • GPIO2: pin is high on BOOT, boot failure if pulled LOW
  • GPIO15: boot failure if pulled HIGH
  • GPIO3: pin is high at BOOT
  • GPIO1: pin is high at BOOT, boot failure if pulled LOW
  • GPIO10: pin is high at BOOT
  • GPIO9: pin is high at BOOTPins HIGH at Boot

There are certain pins that output a 3.3V signal when the ESP8266 boots. This may be problematic if you have relays or other peripherals connected to those GPIOs. The following GPIOs output a HIGH signal on boot:

  • GPIO16
  • GPIO3
  • GPIO1
  • GPIO10
  • GPIO9

Additionally, the other GPIOs, except GPIO5 and GPIO4, can output a low-voltage signal at boot, which can be problematic if these are connected to transistors or relays. You can read this article that investigates the state and behavior of each GPIO on boot.

GPIO4 and GPIO5 are the most safe to use GPIOs if you want to operate relays.

Analog Input

The ESP8266 only supports analog reading in one GPIO. That GPIO is called ADC0 and it is usually marked on the silkscreen as A0.

The maximum input voltage of the ADC0 pin is 0 to 1V if you’re using the ESP8266 bare chip. If you’re using a development board like the ESP8266 12-E NodeMCU kit, the voltage input range is 0 to 3.3V because these boards contain an internal voltage divider.

You can learn how to use analog reading with the ESP8266 with the following guide:

On-board LED

Most of the ESP8266 development boards have a built-in LED. This LED is usually connected to GPIO2.

ESP8266 NodeMCU On-board LEDThe LED works with inverted logic. Send a HIGH signal to turn it off, and a LOW signal to turn it on.

RST Pin

When the RST pin is pulled LOW, the ESP8266 resets. This is the same as pressing the on-board RESET button.

ESP8266 NodeMCU On-board Reset button

GPIO0

When GPIO0 is pulled LOW, it sets the ESP8266 into bootloader mode. This is the same as pressing the on-board FLASH/BOOT button.

ESP8266 NodeMCU GPIO 0 Flash boot buttonGPIO16

GPIO16 can be used to wake up the ESP8266 from deep sleep. To wake up the ESP8266 from deep sleep, GPIO16 should be connected to the RST pin. Learn how to put the ESP8266 into deep sleep mode:

I2C

The ESP8266 doens’t have hardware I2C pins, but it can be implemented in software. So you can use any GPIOs as I2C. Usually, the following GPIOs are used as I2C pins:

  • GPIO5: SCL
  • GPIO4: SDA

SPI

The pins used as SPI in the ESP8266 are:

  • GPIO12: MISO
  • GPIO13: MOSI
  • GPIO14: SCLK
  • GPIO15: CS

PWM Pins

ESP8266 allows software PWM in all I/O pins: GPIO0 to GPIO16. PWM signals on ESP8266 have 10-bit resolution. Learn how to use ESP8266 PWM pins:




from https://www.itread01.com/content/1548371188.html

NodeMCU套件上的PWM引腳

NodeMCU PWM引腳

PWM的Arduino程式

uint8_t LEDpin = D6;

/* By default PWM frequency is 1000Hz and we are using same 
   for this application hence no need to set */

void setup(){
  Serial.begin(9600);
  analogWrite(LEDpin, 512);  /* set initial 50% duty cycle */
}

void loop(){
  uint16_t dutycycle =  analogRead(A0); /* read continuous POT and set PWM duty cycle according */
  if(dutycycle > 1023) dutycycle = 1023;/* limit dutycycle to 1023 if POT read cross it */
  Serial.print("Duty Cycle: ");  Serial.println(dutycycle);
  analogWrite(LEDpin, dutycycle);
  delay(100);
}






from https://zhaomenghuan.js.org/blog/nodemcu-esp8266-gpio-pwm.html



NodeMCU 管脚映射图

留言

熱門文章