Installing ESP32 LoRa on the Arduino IDE

Introduction: Installing ESP32 LoRa on the Arduino IDE

About: Do you like technology? Follow my channel on Youtube and my Blog. In them I put videos every week of microcontrollers, arduinos, networks, among other subjects.

Today, I am going to talk about the installation of ESP32 LoRa in the Arduino IDE. I have already talked about this subject before, but I think it needs an update. I will introduce you the installation of the ESP32 LoRa libraries step by step, both for LoRa communication and for the display. Also, I will show a sample source code using some LoRa and display functions. In this Project, we use the Heltec microcontroller.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Demonstration

Step 2: Resources Used

ESP32 LoRa Heltec

Micro USB to USB cable

Step 3: For Those Who Have Already Installed Esp32

You must delete the following folders:

Step 4: Steps Followed in the Video

1. Installation of the ESP32 card (The Heltec_WiFi_LoRa_32 and Heltec_WiFi_Kit_32 cards will also be installed)

1.1 - In your Arduino IDE go to:

Arduino -> Preferences

In Additional URLs for Cards Managers, add the url:

1.2 - In your Arduino IDE go to:

Tools -> Cards -> Cards Manager

Search for: esp32

Install the package described as: esp32 by Espressif Systems

2. Installation of Silicon Labs CP210x USB drivers for UART Bridge VCP.

Go to:

Download and install the driver compatible with your OS

3. LoRa library installation

In your IDE Arduino go to:

Sketch -> Include library -> Manage libraries

Search for: LoRa

Install the library described as: LoRa (distributed by Sandeep Mistry)

4. Installing the SSD1306 library for the display

In your IDE Arduino go to:

Sketch -> Include library -> Manage libraries

Search for: SSD1306

Install the library described as: ESP8266 and ESP32 Oled Driver for SSD1306 display

Step 5: Code: Declarations and Variables


// Pinos do display (comunicação i2c)

const int DISPLAY_ADDRESS_PIN = 0x3c;

const int DISPLAY_SDA_PIN = 4;

const int DISPLAY_SCL_PIN = 15;

const int DISPLAY_RST_PIN = 16;

// Pinos do lora (comunicação spi)

const int LORA_SCK_PIN = 5;

const int LORA_MISO_PIN = 19;

const int LORA_MOSI_PIN = 27;

const int LORA_SS_PIN = 18;

const int LORA_RST_PIN = 15;

const int LORA_DI00_PIN = 26;

// Frequência de comunicação

const int BAND = 433E6;

// Contador de pacotes enviados via lora

int counter = 0;

// Altura da fonte (correspondente a fonte ArialMT_Plain_16)
const int fontHeight = 16; 
// Objeto do display

Step 6: Code: Setup

void setup() 
  // Iniciamos a serial com velocidade de 9600
  // Exibimos "Starting..." na serial (debug)
  // Iniciamos o display
    // Se não deu certo, exibimos falha de display na serial
    Serial.println("Display failed!");
    // E deixamos em loop infinito
  // Configuramos o posicionamento da tela, fonte e o alinhamento do texto
  // Iniciamos o lora
    // Se não deu certo, exibimos falha de lora na serial
    Serial.println("LoRa failed!");
    // E deixamos em loop infinito
    while (1);

Step 7: Code: Loop

void loop() 
  // Variável usada para indicar em qual linha o cursor deverá estar quando uma mensagem no display for exibida
  int line;
  // Limpamos o display
  // Iniciamos na primeira linha (zero)
  line = 0;
  // Escrevemos a mensagem "Sending packet: " na primeira linha
  display.drawString(0, line, "Sending packet: ");
  // Mudamos para a segunda linha
  // Escrevemos o incrementador "counter" na segunda linha
  display.drawString(0, line * fontHeight, String(counter));
  // Exibimos as alterações no display

  // Enviamos um pacote com a mensagem "hello" concatenado com o número "counter"
  LoRa.print("hello ");
  // Incrementamos o contador
  // Aguardamos 1 segundo

Step 8: Code: Display Begin and Display Config

// Função que inicializa o display
bool displayBegin()
  // Reiniciamos o display
  digitalWrite(DISPLAY_RST_PIN, LOW);
  digitalWrite(DISPLAY_RST_PIN, HIGH);
  return display.init(); 
// Função que faz algumas configuções no display
void displayConfig()
  // Invertemos o display verticalmente
  // Setamos a fonte
  // Alinhamos a fonta à esquerda

Step 9: Code: LoraBegin

// Função que inicializa o radio lora
bool loraBegin()
  // Iniciamos a comunicação SPI
  // Setamos os pinos do lora
  // Iniciamos o lora
  return LoRa.begin(BAND);

Step 10: Compilation Options

Step 11: Download the Files

Be the First to Share


    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest