The LuaNode32 Board: an ESP32 Microcontroller Module

Lecture



The LuaNode32 Board: an ESP32 Microcontroller Module

Home page for the ESP32 board for Arduino on GitHub - github.com/espressif/arduino-esp32

The hardware of the IoT platform is built on the ESP-WROOM-32 module with the ESP32-D0WDQ6 system on a chip made by Espressif.

The ESP32-D0WDQ6 chip — is manufactured using SoC (System-on-a-Chip) technology.

The ESP32-WROOM — is a module containing the ESP32-D0WDQ6 chip, 4 MB of flash memory and all the necessary supporting circuitry, hidden under a metal shield. Next to the shield is a miniature antenna formed by a trace on the top layer of the PCB. The metal shield screens the module's components, thereby improving its electromagnetic properties.

The LuaNode32 Board: an ESP32 Microcontroller Module

The die contains a dual-core 32-bit Tensilica Xtensa LX6 processor, 520 KB of SRAM and 448 KB of flash memory, plus 4 MB of external flash memory. The clock frequency can be set up to 240 MHz depending on the power mode.

It also has a built-in temperature sensor, a Hall sensor, an infrared receive/transmit controller, a touch-button controller, Bluetooth (BLE v4.2 BR/EDR), and Wi-Fi (Wi-Fi 802.11 b/g/n standards (2.4 GHz)).

A USB-to-UART converter based on the CP2102 chip provides the connection between the ESP32-WROOM module and the computer's USB port. When connected to a PC — the ESP32 DevKit board is recognised as a virtual COM port.

The micro-USB connector is used for flashing and powering the ESP32 DevKit board from a computer.

Pins

The LuaNode32 Board: an ESP32 Microcontroller Module

On both sides of the board there are pin headers with 15 pins each, at a 2.54 mm pitch (a 30-pin version also exists).

25 general-purpose pins are available. All pins support interrupts. Maximum current per pin: 12 mA.

  • 21 digital input/output (GPIO) pins: 1–5, 12–19, 21–23, 25–27, 32 and 33. General-purpose pins. Pins can be configured as input or output. Logic level for a one is 3.3 V, for a zero is 0 V. Maximum output current is 12 mA. All I/O pins can operate as PWM, which allows analogue values to be output as a PWM signal with 16-bit resolution. Maximum number of channels: 16
  • 4 digital input-only pins (GPI): 34, 35, 36 and 39. Can only be configured as input.
  • 15 analogue inputs with a 12-bit ADC: 2, 4, 12–15, 25–27, 32–36 and 39. Allows an analogue voltage to be represented digitally with 12-bit resolution
  • 2 analogue outputs with an 8-bit DAC: 25 (DAC1) and 26 (DAC2). The analogue output of the digital-to-analogue converter can generate 8-bit voltage levels. These pins can be used for audio output.
  • 10 capacitive-sensor pins

The I/O pins can be configured to provide hardware interfaces:

  • 3×UART
  • 3×SPI
  • 2×I²C
  • 3× I²S

For experiments, use pins 2, 4, 12, 13, 14, 18, 19, 21, 22, 23, 25, 26, 27.

Summary table of pins for use in projects

Summary table of pins for use in projects

GPIO Input Output Notes
0 pulled up OK outputs PWM signal at boot
1 TX pin OK debug output at boot
2 OK OK connected to on-board LED
3 OK RX pin HIGH at boot
4 OK OK
5 OK OK outputs PWM signal at boot
6 x x connected to the integrated SPI flash
7 x x connected to the integrated SPI flash
8 x x connected to the integrated SPI flash
9 x x connected to the integrated SPI flash
10 x x connected to the integrated SPI flash
11 x x connected to the integrated SPI flash
12 OK OK boot fail if pulled high
13 OK OK
14 OK OK outputs PWM signal at boot
15 OK OK outputs PWM signal at boot
16 OK OK
17 OK OK
18 OK OK
19 OK OK
21 OK OK
22 OK OK
23 OK OK
25 OK OK
26 OK OK
27 OK OK
32 OK OK
33 OK OK
34 OK input only
35 OK input only
36 OK input only
39 OK input only

Power pins

  • VIN: a pin for connecting an external voltage source in the range of 5 to 14 volts (next to GND)
  • 3V3: a pin from the voltage regulator with an output of 3.3 volts and a maximum current of 1 A. The regulator powers the ESP32-WROOM module (next to GND)
  • GND: ground pins (two pins, one on each side)

The development board has two push-buttons. The EN button is used to manually reset the board - the equivalent of the RESET button on a regular computer.

The Boot button is used to manually enter the module's flashing mode. The procedure is as follows: hold down the BOOT button; press and release the EN button; release the BOOT button.

The board also has a power LED and an indicator LED connected to digital pin 2 (instead of pin 13 as on standard Arduino boards).

Power supply

The AMS1117-3.3 linear step-down voltage regulator powers the microcontroller. Output voltage is 3.3 volts with a maximum current of 1 A.

Power is supplied through the micro-USB connector or the Vin pin. The source is detected automatically.

When powering via USB, use a 5V charger together with a Micro USB cable. When powering via Vin, an input voltage of 5 to 14 V is recommended. The board's power converter will regulate the input voltage down to the required 3.3 V.

Important! The logic-level voltage on the pins is 3.3V, connecting 5-volt peripherals may damage the microcontroller!

As with Arduino boards, ESP32 boards also come from different manufacturers with different numbers of pins and different supporting circuitry. Variants of specific boards also appear. For example, the ESP32 DEVKIT DOIT board comes with 30 and 36 pins.

ESP32 specifications

The ESP32 SoC offers substantially improved specifications compared to its predecessor, but it also costs more. So it is up to everyone to decide which one to use.

  • CPU: Xtensa Dual-Core 32-bit LX6, 160 MHz or 240 MHz (up to 600 DMIPS)
  • Memory: 520 KByte SRAM, 448 KByte ROM
  • Flash on the module: 1, 2, 4… 64 MB

Wireless:

  • Wi-Fi: 802.11b/g/n/e/i, up to 150 Mbps with HT40
  • Bluetooth: v4.2 BR/EDR and BLE

Peripheral interfaces:

  • 12-bit SAR ADC, up to 18 channels
  • 2 × 8-bit DAC
  • 10 × touch sensors
  • Temperature sensor
  • 4 × SPI
  • 2 × I²S
  • 2 × I²C
  • 3 × UART
  • 1 host (SD/eMMC/SDIO)
  • 1 slave (SDIO/SPI)
  • Ethernet MAC with DMA and IEEE 1588 support
  • CAN 2.0
  • IR (TX/RX)
  • Motor PWM
  • LED PWM, up to 16 channels
  • Hall sensor
  • Ultra low power analog pre-amplifier

Security:

  • IEEE 802.11 security: WFA, WPA/WPA2 and WAPI
  • Secure boot
  • Flash encryption
  • 1024-bit OTP, including up to 768-bit for user applications
  • Cryptographic: AES, SHA-2, RSA, ECC, RNG

The LuaNode32 Board: an ESP32 Microcontroller Module

Documentation

The LuaNode32 Board: an ESP32 Microcontroller Module

  • Schematic
  • ESP32 SoC documentation
  • ESP Wroom 32 module documentation
  • ESP Wroom 32 module pinout

Appendix

Let's create a project using PlatformIO:

mkdir esp32-intro
cd esp32-intro
pio init -b esp32doit-devkit-v1 --ide vscode

In the src directory, let's create a file called Main.cpp with the following contents (yes, it's the classic blinker):

#include <Esp.h>

void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(100);
    digitalWrite(LED_BUILTIN, LOW);
    delay(900);
}

And in the platformio.ini file, in the [env:esp32doit-devkit-v1] section, let's add a parameter specifying the upload speed:

upload_speed = 921600

In this case it makes sense, since the ESP32 SoC has high performance, and increasing the channel speed improves the upload speed. Although for me it turned out to be variable: from six to ten seconds.

Let's build our application:

pio run

And upload it:

pio run -t upload

Actually, it isn't necessary to give two separate commands. Calling pio run -t upload on its own will rebuild the application if needed. I give two commands purely so I can see how long it takes to upload the application to the board.

The upload process prints a fairly detailed log.

[Fri Sep 29 11:52:53 2017] Processing esp32doit-devkit-v1 (platform: espressif32; upload_speed: 921600; board: esp32doit-devkit-v1; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
Collected 15 compatible libraries
Looking for dependencies...
No dependencies
Looking for upload port...
Auto-detected: /dev/ttyUSB0
Uploading .pioenvs/esp32doit-devkit-v1/firmware.bin
esptool.py v2.1-beta1
Connecting........_
Chip is ESP32D0WDQ6 (revision 1)
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Flash params set to 0x022f
Compressed 10464 bytes to 7012...
Wrote 10464 bytes (7012 compressed) at 0x00001000 in 0.1 seconds (effective 1044.7 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 122...
Wrote 3072 bytes (122 compressed) at 0x00008000 in 0.0 seconds (effective 8280.8 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 35367.7 kbit/s)...
Hash of data verified.
Compressed 356880 bytes to 177296...
Wrote 356880 bytes (177296 compressed) at 0x00010000 in 3.2 seconds (effective 891.6 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting...
==== [SUCCESS] Took 8.46 seconds ====

The log reveals an interesting innovation in the bootloader: the firmware is transferred in compressed form, which considerably speeds up the data transfer process and, as a result, the overall upload speed.

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Digital devices. Microprocessors and microcontrollers. computer operating principles"

Terms: Digital devices. Microprocessors and microcontrollers. computer operating principles