Heltec WiFi LoRa 32 V2 boards

Support for Heltec WiFi LoRa 32 V2 boards. More...

Detailed Description

Support for Heltec WiFi LoRa 32 V2 boards.

Author
Gunar Schorcht gunar.nosp@m.@sch.nosp@m.orcht.nosp@m..net

<a name="toc"> Table of Contents </a>

  1. Overview
  2. Hardware
    1. MCU
    2. Board Configuration
    3. Board Pinout
    4. Using the OLED Display
    5. Optional Hardware Configurations
  3. Flashing the Device

<a name="overview"> Overview </a>    [<a href="#toc">TOC</a>]

Heltec WiFi LoRa 32 V2 is an ESP32 development board with 8 MB Flash that uses the EPS32 chip directly. It integrates

Since the board is open source hardware, a number of clones are available.

Heltec WiFi Lora 32 V2

<a name="hardware"> Hardware </a>    [<a href="#toc">TOC</a>]

This section describes

<a name="mcu"> MCU </a>    [<a href="#toc">TOC</a>]

Most features of the board are provided by the ESP32 SoC. For detailed information about the ESP32, see section MCU ESP32.

<a name="board_configuration"> Board Configuration </a>    [<a href="#toc">TOC</a>]

Heltec WiFi LoRa 32 V2 has the following on-board components:

There are two hardware versions of the board:

Since many GPIOs are broken out, they can be used for different purposes in different applications. For flexibility, some GPIOs might be listed in various peripheral configurations. For example, GPIO0 is used in the ADC channel definition ADC_GPIOS and the PWM channel definition PWM0_GPIOS.

This is possible because GPIOs are only used for a specific peripheral interface when

That is, the purpose for which a GPIO is actually used depends on which module or function is used first.

Note
GPIOs 19, 4, 5, 14, 15, 16, 18, 32, 33, 34, 35, 21, 26, and 27 are used for board control functions and should not be used for other purposes unless you exactly know what you are doing.

The following table shows the default board configuration, which is sorted according to the defined functionality of GPIOs. This configuration can be overridden by application-specific configurations.

Function GPIOs Remarks Configuration
BTN0 GPIO0 low active
LED0 GPIO25 high active
ADC GPIO36, GPIO39, GPIO37, GPIO38,
GPIO0, GPIO2, GPIO12, GPIO13,
GPIO4, GPIO15
ADC Channels
DAC DAC Channels
PWM_DEV(0) GPIO25, GPIO0, GPIO2, GPIO17 PWM Channels
PWM_DEV(1) GPIO22, GPIO23 PWM Channels
I2C_DEV(0):SDA GPIO4 I2C Interfaces
I2C_DEV(0):SCL GPIO15 I2C_SPEED_FAST is used I2C Interfaces
SPI_DEV(0):CLK GPIO5 VSPI is used SPI Interfaces
SPI_DEV(0):MISO GPIO19 VSPI is used SPI Interfaces
SPI_DEV(0):MOSI GPIO27 VSPI is used SPI Interfaces
SPI_DEV(0):CS0 GPIO18 VSPI is used SPI Interfaces
UART_DEV(0):TxD GPIO1 Console (configuration is fixed) UART interfaces
UART_DEV(0):RxD GPIO3 Console (configuration is fixed) UART interfaces
UART_DEV(1):TxD GPIO10 not available in qout and qio flash mode UART interfaces
UART_DEV(1):RxD GPIO9 not available in qout and qio flash mode UART interfaces
OLED RESET GPIO16


Note
  • The configuration of ADC channels contains all ESP32 GPIOs that can be used as ADC channels.
  • GPIO9 and GPIO10 can only be used in dout and dio flash modes.

For detailed information about the configuration of ESP32 boards, see section Common Peripherals.

<a name="oled_display"> Using the OLED Display </a>    [<a href="#toc">TOC</a>]

The 0.96-inch OLED display with 128x64 pixels uses the widely used SSD1306 controller. It is connected via I2C_DEV(0). It can be used with the pkg/u8g2 package. For this purpose, the pkg/u8g2 package has to be used in the application Makefile

USEPKG += u8g2

and function u8g2_Setup_ssd1306_i2c_128x64_noname_f has to be called to setup the right driver, for example:

#include "u8g2.h"
#include "u8x8_riotos.h"
#define SSD1306_I2C_ADDR (0x3c)
u8x8_riotos_t user_data = {
.pin_cs = GPIO_UNDEF,
.pin_dc = GPIO_UNDEF,
.pin_reset = GPIO16,
};
u8g2_Setup_ssd1306_i2c_128x64_noname_f(&u8g2, U8G2_R0,
u8g2_SetUserPtr(&u8g2, &user_data);
u8g2_SetI2CAddress(&u8g2, SSD1306_I2C_ADDR);
u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);

The tests/pkg_u8g2 test application is a good example of how to use the pkg/u8g2 package. It can be compiled for the board with the following command:

TEST_OUTPUT=4 TEST_I2C=0 TEST_ADDR=0x3c TEST_PIN_RESET=GPIO16 \
TEST_DISPLAY=u8g2_Setup_ssd1306_i2c_128x64_noname_f \
BOARD=esp32-heltec-lora32-v2 make -C tests/pkg_u8g2/ flash

<a name="optional_hardware"> Optional Hardware Configurations </a>    [<a href="#toc">TOC</a>]

MRF24J40-based IEEE 802.15.4 radio modules and ENC28J60-based Ethernet network interface modules have been tested with the board. You could use the following code in your application-specific configuration to use such modules:

#ifdef BOARD_ESP32_HELTEC_LORA32_V2
#if MODULE_MRF24J40
#define MRF24J40_PARAM_CS GPIO12 /* MRF24J40 CS signal */
#define MRF24J40_PARAM_RESET GPIO22 /* MRF24J40 RESET signal */
#define MRF24J40_PARAM_INT GPIO23 /* MRF24J40 INT signal */
#endif
#if MODULE_ENC28J80
#define ENC28J80_PARAM_CS GPIO12 /* ENC28J80 CS signal */
#define ENC28J80_PARAM_RESET GPIO22 /* ENC28J80 RESET signal */
#define ENC28J80_PARAM_INT GPIO23 /* ENC28J80 INT signal */
#endif
#endif

For other parameters, the default values defined by the drivers can be used.

Note
The RESET signal of MRF24J40 and ENC28J60 based modules can also be connected to the RST pin of the board (see pinout) to keep the configured GPIO free for other purposes.

<a name="pinout"> Board Pinout </a>    [<a href="#toc">TOC</a>]

The following figure shows the pinout of the defined default configuration for Heltec WiFi LoRa 32 V2 boards. The light green GPIOs are not used by configured on-board hardware components and can be used for any purpose. However, if optional off-board hardware modules are used, these GPIOs may also be occupied, see optional functions in table board configuration.

The corresponding board schematics can be found here for SX1276 version and here for SX1278 version.

WiFi LoRa 32 V2 Pintout Diagram

<a name="flashing"> Flashing the Device </a>    [<a href="#toc">TOC</a>]

Flashing RIOT is quite easy. The board has a Micro-USB connector with reset/boot/flash logic. Just connect the board to your host computer and type using the programming port:

make flash BOARD=esp32-heltec-lora32-v2 ...

For detailed information about ESP32 as well as configuring and compiling RIOT for ESP32 boards, see RIOT-OS on ESP32 boards.

Files

file  arduino_board.h
 Board specific configuration for the Arduino API.
 
file  arduino_pinmap.h
 Mapping from MCU pins to Arduino pins.
 
file  board.h
 Board specific definitions for Heltec WiFi LoRa 32 V2 board.
 
file  gpio_params.h
 Board specific configuration of direct mapped GPIOs.
 
file  periph_conf.h
 Peripheral MCU configuration for Heltec WiFi LoRa 32 V2 board.
 
u8x8_riotos_t::device_index
unsigned int device_index
Index of the SPI/I2C device.
Definition: u8x8_riotos.h:45
u8x8_byte_hw_i2c_riotos
uint8_t u8x8_byte_hw_i2c_riotos(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr)
To be used as the u8x8_msg_cb as gpio_and_delay_cb in u8x8_Setup() for use with RIOT-OS.
I2C_DEV
#define I2C_DEV(x)
Default I2C device access macro.
Definition: i2c.h:133
u8x8_riotos.h
U8g2 driver for interacting with RIOT-OS peripherals.
GPIO_UNDEF
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
Definition: periph_cpu_common.h:52
u8x8_riotos_t
Holds RIOT-OS specific peripheral data.
Definition: u8x8_riotos.h:42
u8x8_gpio_and_delay_riotos
uint8_t u8x8_gpio_and_delay_riotos(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr)
To be used as the u8x8_msg_cb as gpio_and_delay_cb in u8x8_Setup() for use with RIOT-OS.