ESP32 Project: Build a Secure, Long-Range LoRa Chat Device Heltec WiFi LoRa 32 on N33
Build a Secure, Off-Grid LoRa Messenger with a Custom Keyboard
In a world that relies on constant connectivity, what do you do when the Wi-Fi is down, the power is out, and cellular service is gone? This project tackles that exact problem by creating a completely self-sufficient, off-grid communication device that allows you to send and receive secure, private text messages over distances of up to 13 miles (21km) or even more.
This device is a practical tool for emergency preparedness, outdoor adventures like hiking, or simply for anyone interested in building a robust, private communication network that they control. Using a powerful Heltec WiFi LoRa 32 V3 module packed inside a durable Meshnology N33 case with a long-lasting 3000mAh battery, this project is built for real-world use. The most unique feature is its keyboard—a simple rotary encoder that provides an intuitive and reliable way to type messages anywhere, anytime.
How It Works: The Magic of LoRa and a Rotary Encoder
The project combines three key concepts to create a functional messenger:
- LoRa Radio: LoRa (Long Range) is a radio technology that allows for communication over vast distances with very little power. Unlike Wi-Fi or cellular, it operates on license-free radio frequencies, meaning there are no SIM cards or monthly fees involved. Our device operates as a full transceiver, meaning it can both send and receive messages. When idle, it listens for incoming packets. After sending or receiving a message, it puts the radio to sleep momentarily to conserve power before returning to listening mode.
- Rotary Encoder Keyboard: Instead of a bulky or power-hungry keyboard, we use a simple rotary encoder for text input. Rotating the knob cycles through a complete character set (A-Z, a-z, numbers, and symbols). The interface is surprisingly fast and responsive, allowing you to easily compose messages. The encoder's built-in push-button has three functions:
- Short Press (Click): Adds the selected character to your message.
- Long Press (Hold): Adds a space, like a spacebar.
- Double-Click: Acts as a backspace to delete the last character.
- Transceiver & Display Logic: The device has two main modes: "Compose" and "Read". You type your message in Compose mode. When a new message arrives, a notification appears on the screen (
>> NEW MSG <<). You can then press the onboard User Button (on the Heltec board) to switch to Read mode and view the message. Another press switches you back to Compose mode to type your reply. All messages are secured using AES encryption, ensuring your conversations remain private.
Components and Parts List
To build this project, you will need the following components. As mentioned in the video, purchasing through affiliate links is a great way to support creators.
- Heltec WiFi LoRa 32 V3 Module
- Meshtastic N33 Case with 3000mAh Battery
- 915MHz or region-appropriate LoRa Antenna
- Rotary Encoder Module (5-pin with VCC, GND, CLK, DT, SW)
- Optional (for audio alerts):
- 5V Active Buzzer
- 2N2222 NPN Transistor
- 1kΩ Resistor
- Pin Headers and Jumper Wires
- Soldering Iron and accessories
Setting Up Your Arduino IDE
Before you can upload the code, you need to configure the Arduino IDE with the correct boards and libraries. This process is detailed in the video starting around 05:38.
Step 1: Install the ESP32 Boards
If you haven't already, you need to add support for ESP32 microcontrollers.
- Open the Arduino IDE, go to
File > Preferences. - In the "Additional boards manager URLs" field, add the following URL:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json - Go to
Tools > Board > Boards Manager.... - Search for
esp32and install the package by Espressif Systems.
Step 2: Add the Heltec ESP32 Board Support
- In
File > Preferences, add the Heltec JSON URL on a new line in the "Additional boards manager URLs" box (the video shows how to do this at 06:27):https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/releases/download/0.0.7/package_heltec_esp32_index.json - Go back to
Tools > Board > Boards Manager.... - Search for
Heltec ESP32and install the package.
Step 3: Install Required Libraries from Library Manager
Using the Arduino Library Manager (Sketch > Include Library > Manage Libraries...), search for and install the following libraries:
- Ai Esp32 Rotary Encoder: The specific library used for our responsive keyboard.
- Heltec ESP32 Dev-Boards: The official library for the Heltec hardware.
- Adafruit GFX Library: A dependency for the OLED display.
Step 4: Install the Robojax Helper Library from .ZIP
As explained in the video at 18:53, a custom helper library is used for this project. You must install it from a .zip file.
- Download the "Robojax HealthTech Lora 32" .zip library from the link provided on the resources page.
- In the Arduino IDE, click on
Sketch > Include Library > Add .ZIP Library.... - Navigate to where you saved the downloaded .zip file, select it, and click "Open".
- The library will be installed and ready to use.
After installing everything, make sure you select the correct board from the menu: Tools > Board > Heltec ESP32 Arduino > Heltec WiFi LoRa 32 V3.
Wiring the Components
You will need to solder pin headers to your Heltec board to connect the rotary encoder. As shown in the video (11:25), careful planning is needed to ensure the pins are accessible once the board is in its case.

Diagram 1: Core Messenger (Rotary Encoder Only)
Connect the 5 pins from the rotary encoder module to the Heltec board as follows:
GNDon encoder →GNDon Heltec boardVCCon encoder →3.3Von Heltec boardSW(Switch) →GPIO 4DT(Data/Pin B) →GPIO 6CLK(Clock/Pin A) →GPIO 5

Diagram 2: Adding an Audible Alert (Buzzer Circuit)
To get an audible beep when a new message arrives, you can add a simple transistor circuit. This is necessary because the ESP32's pins cannot provide enough current to drive a buzzer directly.
- Connect
GPIO 40from the Heltec board to one end of the 1kΩ resistor. - Connect the other end of the resistor to the Base pin of the 2N2222 transistor.
- Connect the Emitter pin of the transistor to
GND. - Connect the positive (+) leg of the 5V buzzer to the
3.3Vpin on the Heltec board. - Connect the negative (-) leg of the buzzer to the Collector pin of the transistor.
Understanding and Customizing the Code
The provided code is ready to upload, but there are a few key settings you should be aware of so you can customize the project. These definitions are at the top of the code.
// Defines for physical pin connections
#define ROTARY_ENCODER_A_PIN 5 //pin A of rotary encoder
#define ROTARY_ENCODER_B_PIN 6 //pin B of rotary encoder
#define ROTARY_ENCODER_BUTTON_PIN 4 //switch pin of rotary encoder
#define BUZZER_PIN 40 //the buzzer pin or relay to be triggered
const bool DEBUG = false;
// Defines for LoRa and Security settings
#define RF_FREQUENCY 915432000 //operating frequency of LoRa
#define TX_OUTPUT_POWER 2 //output power should be between 2 to 21 in dBm.
const char *userKey = "xxxBg^Tr%43232";//security key for private communication
ROTARY_ENCODER_...: These pins define where you connected your rotary encoder. Make sure these numbers match your wiring from the diagrams above.BUZZER_PIN: This defines which pin will trigger the buzzer circuit.RF_FREQUENCY: This is the LoRa operating frequency in Hertz. The value 915432000 (915 MHz) is standard for North America. You must change this value according to your region (e.g., 868MHz for Europe, 433MHz for Asia). All devices that want to communicate must use the same frequency.TX_OUTPUT_POWER: This is the transmission power in dBm. It can range from 2 to 20. A lower number like2is perfect for short-range testing and saves a significant amount of battery. For maximum range, you can increase this value, but be aware that higher power drains the battery much faster.userKey: This is your private encryption key. It can be any combination of characters. All devices must have the exact same key to decrypt each other's messages. Change this to your own unique and secret password.
Get the Code
The complete and final Arduino code for this project, as referenced in the video, is available for download on this page.
Video Chapters
- 00:00 - Introduction
- 00:56 - Project Outline
- 01:29 - Components Overview
- 05:25 - Unboxing and Hardware Assembly
- 11:19 - Case Modification for External Wires
- 15:06 - Wiring Guide
- 15:38 - Arduino IDE and Library Setup
- 20:21 - Code Settings Explained
- 21:38 - How to Use the Rotary Encoder to Chat
- 24:26 - Live Range Test
Ressourcen & Referenzen
-
ExternPurchase Wi-Fi LoRa 32 from Meshnologymeshnology.com
Dateien📁
Andere Dateien
-
Robojax Heltec WiFi LoRa 32 Library Version 1.1.0 20250703
Robojax_HeltecLoRa32_1.1.0_20250702.zip0.09 MB