Adsense HTML/JavaScript

Monday, October 25, 2021

arduino-esp32, list the pre-defined function pins of ESP32C3/S2 Dev Module

With arduino-esp32 2.0.0 installed on Arduino IDE, the following exercise run on ESP32-C3-DevKitM-1/ESP32-S2-Saola-1 to list the pre-defined function pins of ESP32C3/S2 Dev Module.

This video also show how to locate pins_arduino.h where it defined.


Test on ESP32-C3-DevKitM-1, ESP32-S2-Saola-1 and ESP32-DevKitC V4.

ESP32C3_pins.ino for board of ESP32C3 Dev Module, run on ESP32-C3-DevKitM-1
void setup() {
  // put your setup code here, to run once:
  delay(500);
  Serial.begin(115200);
  delay(500);
  Serial.println("\n\n================================");
  Serial.printf("Chip Model: %s\n", ESP.getChipModel());
  Serial.println("================================");

#ifdef EXTERNAL_NUM_INTERRUPTS
  Serial.printf("EXTERNAL_NUM_INTERRUPTS = %d\n", EXTERNAL_NUM_INTERRUPTS);
#endif
#ifdef NUM_DIGITAL_PINS
  Serial.printf("NUM_DIGITAL_PINS = %d\n", NUM_DIGITAL_PINS);
#endif
#ifdef NUM_ANALOG_INPUTS
  Serial.printf("NUM_ANALOG_INPUTS = %d\n", NUM_ANALOG_INPUTS);
#endif
  Serial.println();
  Serial.printf("Default TX:   %d\n", TX);
  Serial.printf("Default RX:   %d\n", RX);
  Serial.println();
  Serial.printf("Default SDA:  %d\n", SDA);
  Serial.printf("Default SCL:  %d\n", SCL);
  Serial.println();
  Serial.printf("Default SS:   %d\n", SS);
  Serial.printf("Default MOSI: %d\n", MOSI);
  Serial.printf("Default MISO: %d\n", MISO);
  Serial.printf("Default SCK:  %d\n", SCK);
  Serial.println();
  Serial.printf("Default A0:   %d\n", A0);
  Serial.printf("Default A1:   %d\n", A1);
  Serial.printf("Default A2:   %d\n", A2);
  Serial.printf("Default A3:   %d\n", A3);
  Serial.printf("Default A4:   %d\n", A4);
  Serial.printf("Default A5:   %d\n", A5);
  Serial.println("================================");
}

void loop() {
  // put your main code here, to run repeatedly:

}


output:
================================
Chip Model: ESP32-C3
================================
EXTERNAL_NUM_INTERRUPTS = 22
NUM_DIGITAL_PINS = 22
NUM_ANALOG_INPUTS = 6

Default TX:   21
Default RX:   20

Default SDA:  8
Default SCL:  9

Default SS:   7
Default MOSI: 6
Default MISO: 5
Default SCK:  4

Default A0:   0
Default A1:   1
Default A2:   2
Default A3:   3
Default A4:   4
Default A5:   5
================================

ESP32-C3-DevKitM-1 Pin Layout


ESP32S2_pins.ino for board of ESP32S2 Dev Module, run on ESP32-S2-Saola-1
void setup() {
  // put your setup code here, to run once:
  delay(500);
  Serial.begin(115200);
  delay(500);
  Serial.println("\n\n================================");
  Serial.printf("Chip Model: %s\n", ESP.getChipModel());
  Serial.println("================================");

#ifdef EXTERNAL_NUM_INTERRUPTS
  Serial.printf("EXTERNAL_NUM_INTERRUPTS = %d\n", EXTERNAL_NUM_INTERRUPTS);
#endif
#ifdef NUM_DIGITAL_PINS
  Serial.printf("NUM_DIGITAL_PINS = %d\n", NUM_DIGITAL_PINS);
#endif
#ifdef NUM_ANALOG_INPUTS
  Serial.printf("NUM_ANALOG_INPUTS = %d\n", NUM_ANALOG_INPUTS);
#endif
  Serial.println();
  Serial.printf("Default TX:   %d\n", TX);
  Serial.printf("Default RX:   %d\n", RX);
  Serial.println();
  Serial.printf("Default SDA:  %d\n", SDA);
  Serial.printf("Default SCL:  %d\n", SCL);
  Serial.println();
  Serial.printf("Default SS:   %d\n", SS);
  Serial.printf("Default MOSI: %d\n", MOSI);
  Serial.printf("Default MISO: %d\n", MISO);
  Serial.printf("Default SCK:  %d\n", SCK);

  Serial.println();
  Serial.printf("A0\tA1\tA2\tA3\tA4\tA5\tA6\tA7\tA8\tA9\n");
  Serial.printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", 
                 A0, A1, A2, A3, A4, A5, A6, A7, A8, A9);
  Serial.println();
  Serial.printf("A10\tA11\tA12\tA13\tA14\tA15\tA16\tA17\tA18\tA19\n");
  Serial.printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", 
                 A10, A11, A12, A13, A14, A15, A16, A17, A18, A19);
  Serial.println();

  Serial.printf("T1\tT2\tT3\tT4\tT5\tT6\tT7\tT8\tT9\tT10\n");
  Serial.printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", 
                 T1, T2, T3, T4, T5, T6, T7, T8, T9, T10);
  Serial.println();
  Serial.printf("T11\tT12\tT13\tT14\n");
  Serial.printf("%d\t%d\t%d\t%d\n", 
                 T11, T12, T13, T14);
  Serial.println();
  Serial.printf("Default DAC1:  %d\n", DAC1);
  Serial.printf("Default DAC2:  %d\n", DAC2);
  Serial.println("================================");
}

void loop() {
  // put your main code here, to run repeatedly:

}


output:
================================
Chip Model: ESP32-S2
================================
EXTERNAL_NUM_INTERRUPTS = 46
NUM_DIGITAL_PINS = 48
NUM_ANALOG_INPUTS = 20

Default TX:   43
Default RX:   44

Default SDA:  8
Default SCL:  9

Default SS:   34
Default MOSI: 35
Default MISO: 37
Default SCK:  36

A0	A1	A2	A3	A4	A5	A6	A7	A8	A9
1	2	3	4	5	6	7	8	9	10

A10	A11	A12	A13	A14	A15	A16	A17	A18	A19
11	12	13	14	15	16	17	18	19	20

T1	T2	T3	T4	T5	T6	T7	T8	T9	T10
1	2	3	4	5	6	7	8	9	10

T11	T12	T13	T14
11	12	13	14

Default DAC1:  17
Default DAC2:  18
================================


ESP32-S2-Saola-1 Pin Layout


ESP32_pins.ino for board of ESP32 Dev Module, run on ESP32-DevKitC V4
void setup() {
  // put your setup code here, to run once:
  delay(500);
  Serial.begin(115200);
  delay(500);
  Serial.println("\n\n================================");
  Serial.printf("Chip Model: %s\n", ESP.getChipModel());
  Serial.println("================================");

#ifdef EXTERNAL_NUM_INTERRUPTS
  Serial.printf("EXTERNAL_NUM_INTERRUPTS = %d\n", EXTERNAL_NUM_INTERRUPTS);
#endif
#ifdef NUM_DIGITAL_PINS
  Serial.printf("NUM_DIGITAL_PINS = %d\n", NUM_DIGITAL_PINS);
#endif
#ifdef NUM_ANALOG_INPUTS
  Serial.printf("NUM_ANALOG_INPUTS = %d\n", NUM_ANALOG_INPUTS);
#endif
  Serial.println();
  Serial.printf("Default TX:   %d\n", TX);
  Serial.printf("Default RX:   %d\n", RX);
  Serial.println();
  Serial.printf("Default SDA:  %d\n", SDA);
  Serial.printf("Default SCL:  %d\n", SCL);
  Serial.println();
  Serial.printf("Default SS:   %d\n", SS);
  Serial.printf("Default MOSI: %d\n", MOSI);
  Serial.printf("Default MISO: %d\n", MISO);
  Serial.printf("Default SCK:  %d\n", SCK);

  Serial.println();
  Serial.printf("A0\t\t\tA3\tA4\tA5\tA6\tA7\n");
  Serial.printf("%d\t\t\t%d\t%d\t%d\t%d\t%d\n", 
                 A0, A3, A4, A5, A6, A7);
  Serial.println();
  Serial.printf("A10\tA11\tA12\tA13\tA14\tA15\tA16\tA17\tA18\tA19\n");
  Serial.printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", 
                 A10, A11, A12, A13, A14, A15, A16, A17, A18, A19);
  Serial.println();

  Serial.printf("T0\tT1\tT2\tT3\tT4\tT5\tT6\tT7\tT8\tT9\n");
  Serial.printf("%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", 
                 T0, T1, T2, T3, T4, T5, T6, T7, T8, T9);
  Serial.println();

  Serial.printf("Default DAC1:  %d\n", DAC1);
  Serial.printf("Default DAC2:  %d\n", DAC2);
  Serial.println("================================");
}

void loop() {
  // put your main code here, to run repeatedly:

}

output:
================================
Chip Model: ESP32-D0WDQ5
================================
EXTERNAL_NUM_INTERRUPTS = 16
NUM_DIGITAL_PINS = 40
NUM_ANALOG_INPUTS = 16

Default TX:   1
Default RX:   3

Default SDA:  21
Default SCL:  22

Default SS:   5
Default MOSI: 23
Default MISO: 19
Default SCK:  18

A0			A3	A4	A5	A6	A7
36			39	32	33	34	35

A10	A11	A12	A13	A14	A15	A16	A17	A18	A19
4	0	2	15	13	12	14	27	25	26

T0	T1	T2	T3	T4	T5	T6	T7	T8	T9
4	0	2	15	13	12	14	27	33	32

Default DAC1:  25
Default DAC2:  26
================================


ESP32-DevKitC V4 Pin Layout
source: ESP32-DevKitC V4 Getting Started Guide :Pin Layout

Remark:
Please notice that GPIO8 on ESP32-C3-DevKitM-1 and GPIO18 on ESP32-S2-Saola-1 are connected to onboard RGB LED. Ref last post "Drive ESP32-C3-DevKitM-1/ESP32-S2-Saola-1 on-board RGB LED (WS2812) in Arduino Framework".

No comments:

Post a Comment