반응형

특징: 듀얼 CPU - 코어0: WiFi, Bluetooth, SPI, I2C, ADC 등 실행

                     - 코어1: 코드 실행

        CPU 속도: 아두이노 IDE 환경에서는 240MHz 고정

        메모리: 4M 플래쉬 (코드 저장),

                  448 KBytes ROM(부팅),

                  520 KBytes on-chip SRAM,

                  16 KB SRAM in RTC

        PWM 핀: 16개 채널(16개 동시 사용가능)

        ADC (Analog Input Pins): 16개(12bit 해상도)

        DAC (Analog Outputs Pins) : 2개

        통신: 하드웨어 Serial 3개, I2C 2개, SPI 2개, wifi, 블루투스

        정전식 터치핀 : 10개

        모든 GPIO 핀에서 인터럽트 설정 가능

        사용전압: 3.3V

        입력전압: 5 ~ 12V

esp32_datasheet_en.pdf
다운로드
esp32_bluetooth_networking_user_guide_en.pdf
다운로드
esp32_technical_reference_manual_en.pdf
다운로드
esp32-wroom-32_datasheet_en.pdf
다운로드

 

 

 

 

 

주의사항

1. 입력 전용핀 : GPIOs 34 ~ 39 입력만 가능(내장 풀업저항 없으므로 저항없이 버튼 연결 안됨)

2. GPIO 6 ~ 11 은 입력/출력 핀으로 사용불가 - 코드 저장용 4M 플래시와의 연결에 사용됨

3. 아두이노 기본 함수인 analogWrite() 함수 사용불가, 대체함수 사용해야함

 

사용에 주의해야할 GPIO NO.(특별한 경우가 아니면 사용하지 않는게 좋음)
0   outputs PWM signal at boot, must be LOW to enter flashing mode, wpu : 스케치 업로드 제어핀
2   connected to on-board LED, strapping pin, wpu : 온보드 플래시
5   outputs PWM signal at boot, strapping pin, wpu : 부팅시 해당핀으로 PWM 값출력 되므로 센서등의 연결에 주의
12  boot fails if pulled high, strapping pin(TDI), wpd  
14  outputs PWM signal at boot  : 부팅시 해당핀으로 PWM 값출력 되므로 센서등의 연결에 주의
15  outputs PWM signal at boot, strapping pin(TDO), wpu : 부팅시 해당핀으로 PWM 값출력 되므로 센서등의 연결에 주의

* wpu: internal pull-up, wpd: internal pull-down

* strapping pin : 부팅시 특정 상태를 설정하는 핀

 

참조 사이트

https://randomnerdtutorials.com/esp32-pinout-reference-gpios/

 

 

 

 

아두이노 IDE의 환경설정으로 들어가서 추가적인 보드 매니저 URLs의 우측 추가 버튼을 클릭한 뒤 아래 URL을 입력하고 확인을 클릭한다.

 

https://dl.espressif.com/dl/package_esp32_index.json

 

아래 그림에는 ESP8266 아두이노 코어 설치용 URL이 먼저 설정되어 있는 상태이다. 

 

 

툴 -> 보드 -> 보드 매니저를 클릭한다. 

 

 

보드 매니저 타입에 esp32를 입력하면 아래의 화면을 볼 수 있다. 설치를 클릭해준다.

 

 

 

파일 다운로드 과정을 확인 할 수 있다. 다운로드에 약 20분 정도 소요된다.

 

 

 

 

다운로드후 설치가 완료되면 보드 매니저를 닫고 툴 -> 보드에 들어가 보면 ESP32 계열 보드들의 목록을 확인 할 수 있다. 

 

 

 

 

 

 

 

ESP32 Devkit을 사용한다면 ESP32 Dev Module을 선택하면 된다. 

 

설치된 코어의 경로를 확인 하고자 한다면 환경설정의 C:\Users\Administrator\AppData\Local\Arduino15\preferences.txt를 클릭한다.

 

 

 

 

 

 

 

packages 폴더 안의 아래 경로를 확인 할 수 있다. 

 

 

 

시리얼 드라이버 설치 

모델에 따라서 UART 칩셋으로 보통 CH340 또는 CP210x를 사용하는데 이 칩셋용 드라이버가 설치되어 있지 않다면 시리얼 모니터를 열수 없고 스케치의 업로드도 할 수 없게된다. 

제어판의 장치관리자에서 포트항목을 펼쳤을때 CH340 포트 또는 CP210x 포트가 없다면 모듈을 USB로 연결한 상태(어떤 칩셋을 사용하는지 모를 경우)에서 아래 드라이버를 설치해 주면 포트가 생성되고 시리얼 모니터를 사용할 수 있게 된다.

CP210x_Universal_Windows_Driver.zip
0.83MB
CH34x_Install_Windows_v3_4.zip
0.18MB

https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers

 

CP210x USB to UART Bridge VCP Drivers - Silicon Labs

The CP210x USB to UART Bridge Virtual COM Port (VCP) drivers are required for device operation as a Virtual COM Port to facilitate host communication with CP210x products. These devices can also interface to a host using the direct access driver.

www.silabs.com

https://sparks.gogo.co.nz/ch340.html

 

CH340 Drivers for Windows, Mac and Linux

COVID-19 Level 4 Update: New Zealand is in Alert Level 4 - purchases made during Level 4 might be delayed for shipping until Level 3 or lower, it is not yet certain!

 

 

그동안 노트북에서 스케치를 ESP32모듈에 업로드 했었는데, 구형 데스크탑에서 아두이노 IDE를 새로 설치하고 새로운 모듈 ESP32에 스케치를 업로드한 뒤에 아래와 같은 메세지를 출력하면서 무한 리부팅되는 현상이 발생하였다. 

rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1100
load:0x40078000,len:9232
load:0x40080400,len:6400
entry 0x400806a8

 

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371 

 

아두이노 IDE의 툴 -> Flash frequency항목에서 40MHz로 변경해주어 스케치는 업로드 할 수 있게되었으나 업로드 진행이 연속적으로 되지않고 중간에 한번씩 멈추면서 진행되며 몇번은 문제없이 스케치를 업로드 할수 있었는데 아무래도 모듈의 플레시 메모리에 데미지가 발생한거 같다. 용량이 작은 기본 스케치는 업로드가 되나 테스트 코드가 추가된 스케치는 업로드중 30% ~ 40% 사이구간에서 FATAL ERROR발생하며 응답을 수신하지 못했다는 메세지와 함께 업로드가 중지되었다. ESP32의 플레쉬 메모리를 완전히 지우고 공장초기화하는 프로그램 "flash_download_tools_v3.6.3_0"을 사용해도 진행은 되지만 완료하지 못하고 중간에 오류가 발생 되었다. 모듈 불량 또는 데미지를 입은것으로 생각된다. 

 

flash_download_tools_v3.6.3_0.rar
6.61MB

 

예상되는 원인

1. USB 포트 문제: 노트북과 데스크탑을 번갈아 가며 테스트 해보자.

2. 모듈 불량 또는 포트 문제로 발생한 메모리 데미지

 

다른 모듈로 테스트 해보니 Flash frequency "80MHz" 와 Flash Mode "QIO" 옵션 상태에서 같은 현상이 발생하였으나 공장초기화하는 프로그램 "flash_download_tools_v3.6.3_0"으로 Flash메모리를 모두 지우는 작업은 잘되었다.

 

아두이노 IDE의 Flash Mode항목을 "DIO"로 변경하여 스케치를 업로드 할수 있었다.

FATAL ERROR가 발생한 모듈을 불량인것으로 판단되며, 40MHz에서 업로드 되는 모듈은 특정 공장 또는 시기에 생산된 경우 발생하는 것으로 생각되고 업로드 및 MCU 작동은 정상적으로 잘되었다.

 

 

ESP8266 & ESP32의 Flash Mode 옵션 설명

In order of performance:

Option Mode  NamePins  UsedSpeed (ESP8266 & ESP32)
qio Quad I/O 4 pins used for address & data Fastest.
qout Quad Output 4 pins used for data. Approx 15% slower than qio.
dio Dual I/O 2 pins used for address & data Approx 45% slower than qio.
dout Dual Output 2 pins used for data. Approx 50% slower than qio.

모든 ESP8266 & ESP32 모듈이 4가지 옵션을 지원하는것은 아니지만 일반적으로 가장 빠른 QIO옵션을 사용하라고 되어있다. 

https://github.com/espressif/esptool/wiki/SPI-Flash-Modes

 

 

[arduino] - Esp8266 NodeMcu 및 ESP32 Dev Module, stack 오류

 

 

참조 사이트

https://github.com/espressif/arduino-esp32

 

 

• Xtensa® single-/dual-core 32-bit LX6 microprocessor(s), up to 600 MIPS 

  (200 MIPS for ESP32-S0WD, 400 MIPS for ESP32-D2WD)

  160Mhz upto 240MHz 고정 - 80 / 160 낮추려면 프로그램 필요

  Protocol CPU (PRO_CPU) : WiFi, Bluetooth, SPI, I2C, ADC etc. : core0

  Application CPU (APP_CPU) : for the application code.: core1

  ESP-IDF is the official software development framework for the chip.

  Arduino and other implementations for the development will be based on ESP-IDF.

  ESP-IDF uses freeRTOS for switching between the processors and data exchange between them.

 

Internal Memory

• 448 KBytes ROM for booting and core functions.

• 520 KBytes on-chip SRAM for data and instruction.

• 16 KB SRAM in RTC

  * 8 KBytes SRAM in RTC, which is called RTC SLOW Memory and can be accessed by the co-processor during the Deep-sleep mode.

  * 8 KBytes SRAM in RTC, which is called RTC FAST Memory and can be used for data storage;

 

• 1 Kbit of EFUSE, of which 256 bits are used for the system (MAC address and chip configuration) 

• remaining 768 bits are reserved for customer applications, including Flash-Encryption and Chip-ID

 

external Flash-W25Q32 (4M Bytes!): for storing the application code. 

 

external QSPI flash and SRAM: supports 4 x 16 MBytes

 

I2C 21(SDA), 22(SCL) Two I2C devices in slave or master mode  
UART Any GPIO Pins Two UART devices with hardware
flow-control and DMA
GPIO01 TX0   ESP32 has three UART interfaces, i.e., UART0, UART1 and UART2, which provide asynchronous communication (RS232 and RS485) and IrDA support, communicating at a speed of up to 5 Mbps. UART provides hardware management of the CTS and RTS signals and software flow control (XON and XOFF). All of the interfaces can be
accessed by the DMA controller or directly by the CPU
GPIO03 RX0  
GPIO10 TX1 FLASH
GPIO09 RX1 FLASH
GPIO17 TX2  
GPIO16 RX2  
•Digital I/O Pins (DIO): 28          
18 x ADC input channels •Analog Input Pins (ADC): 18
2 x DAC •Analog Outputs Pins (DAC): 2
3 x UARTs, including hardware flow control
3 x SPI   SPI SPI: MOSI MISO CLK CS 
      HSPI:  GPIO 13  GPIO 12 GPIO 14 GPIO 15 
      VSPI:  GPIO 23 GPIO 19 GPIO 18 GPIO 5 
2 x I2S

2 x I2C       GPIO21(SDA), GPIO22(SCL) / 라이브러리에서 핀 변경 가능 -> Wire.begin(I2C_SDA, I2C_SCL);

16 x PWM Chnnel - PWM/timer input/output available on every GPIO pin
•Microcontroller: Tensilica 32-bit Single-/Dual-core CPU Xtensa LX6  
•Operating Voltage: 3.3V          
•Input Voltage: 7-12V          
•Flash Memory: 4 MB          
•SRAM: 520 KB            
•Clock Speed: 240 Mhz          
•Wi-Fi: IEEE 802.11 b/g/n/e/i:          
OpenOCD debug interface with 32 kB TRAX buffer      
SDIO master/slave 50 MHz          
Supports external SPI flash up to 16 MB        
SD-card interface support          
               
Input only pins - GPI 핀          
GPIOs 34 to 39 are GPIs – input only pins.       
These pins don’t have internal pull-ups or pull-down resistors. - 내장 풀업저항 없으므로 저항없이 버튼 연결 안됨
They can’t be used as outputs, so use these pins only as inputs:  
               
GPIO 6 to GPIO 11 are exposed in some ESP32 development boards.   
However, these pins are connected to the integrated SPI flash on the ESP-WROOM-32 chip 
and are not recommended for other uses.       
So, don’t use these pins in your projects:        
               
Capacitive touch GPIOs          
The capacitive touch pins can also be used to wake up the ESP32 from deep sleep.
               
The ADC input channels have a 12 bit resolution.       
This means that you can get analog readings ranging from 0 to 4095,   
in which 0 corresponds to 0V and 4095 to 3.3V. You also have the ability 
to set the resolution of your channels on the code, as well as the ADC range.
               
The ESP32 ADC pins don’t have a linear behavior.       
You’ll probably won’t be able to distinguish between 0 and 0.1V, or between 3.2 and 3.3V. 
You need to keep that in mind when using the ADC pins.     
You’ll get a behavior similar to the one shown in the following figure.

 

 

 

Analog to digital converter or Analog GPIO pins (아날로그 -> 디지털 컨버터: 아날로그 입력)
Mapping of Analog pins with GPIO pins is shown below:

ADC1_CH0 – GPIO36
ADC1_CH1 – GPIO37
ADC1_CH2 – GPIO38
ADC1_CH3 – GPIO39
ADC1_CH4 – GPIO32
ADC1_CH5- GPIO33
ADC1_CH6 – GPIO34
ADC1_CH7 – GPIO35
ADC2_CH0 – GPIO4
ADC2_CH1 – GPIO0
ADC2_CH2 – GPIO2
ADC2_CH3 – GPIO15
ADC2_CH4 – GPIO13
ADC2_CH5 – GPIO12
ADC2_CH6 – GPIO14
ADC2_CH7 – GPIO27
ADC2_CH8 – GPIO25
ADC2_CH9 – GPIO26

* ADC2는 와이파이 드라이버와 공유되고 있어 와이파이가 작동하고 있을 때 ADC2의 모든 아날로그 입력은 4095값으로 판독되므로 사용불가 와이파이를 끈다음에는 사용 가능.

 

RTC GPIOs                
There is RTC GPIO support on the ESP32.           
The GPIOs routed to the RTC low-power subsystem can be used when the ESP32 is in deep sleep. 
These RTC GPIOs can be used to wake up the ESP32 from deep sleep when the Ultra Low Power (ULP) 
co-processor is running. The following GPIOs can be used as an external wake up source.  
                   
PWM 서보모터 16개 사용가능            
The ESP32 LED PWM controller has 16 independent channels that can be configured   
to generate PWM signals with different properties. All pins that can act as outputs   
can be used as PWM pins  (GPIOs 34 to 39 can’t generate PWM).      
                   
Interrupts                  
All GPIOs can be configured as interrupts.          
                   
Enable (EN)                
Enable (EN) is the 3.3V regulator’s enable pin. It’s pulled up, so connect to ground   
to disable the 3.3V regulator. This means that you can use this pin connected to     
a pushbutton to restart your ESP32, for example.          
                   
GPIO current drawn                
The absolute maximum current drawn per GPIO is 40mA according to the     
“Recommended Operating Conditions” section in the ESP32 datasheet.      
                   
                   

 

 

 

 

 

 

 

 

+ Recent posts