In this tutorial, you’ll learn how to set up a secure, offline mesh network using ESP32 LoRa boards with the SX1262 chip and Meshtastic firmware. These boards can communicate long distances without Wi-Fi or cellular data, making them perfect for off-grid messaging, emergency systems, and DIY mesh experiments.
If you'd like expert leven assistance with LoRa networks or anything IoT related you can hire ShillehTek on UpWork or subscribe on YouTube for more guides like this.
FYI ports on windows, linux, and mac are different. Keep that in mind I am using a mac which does not use COM ports to communicate with ESP32s.
What You'll Need
- 2x ESP32 LoRa V3 boards (SX1262, OLED, CP2102)
- USB-C cables with data and power transmission. Some only have power!
- Antennas attached!
- Python 3.9+ with
pip
on your system, we will be using meshstatic cli.
Step 1 – Install the Meshtastic CLI
Meshtastic provides an official command-line tool (CLI) to flash firmware, configure radios, and send messages over the mesh. First, we’ll install it in a Python virtual environment to keep things clean and self-contained.
Run the following commands in your terminal:
python3 -m venv meshtastic-env
source meshtastic-env/bin/activate
pip install -U meshtastic
This creates an isolated Python environment named meshtastic-env
, activates it, and installs the latest version of the Meshtastic CLI inside.
Step 2 – Flash Meshtastic Firmware
Before we use the CLI, we need to install the Meshtastic firmware onto each ESP32 LoRa board. The easiest way is using the official Meshtastic Web Installer.
Here’s how to do it:
- Open https://flasher.meshtastic.org in Chrome or Edge.
- Plug in one board via USB-C.
- Click “Connect”, then select your USB serial port (e.g.
/dev/cu.usbserial-0001
). You should see it in the options once it prompts you to select, make sure its connected to your computer properly. - Select Heltec v3 as the device type when prompted.
- Flash the firmware and wait for it to finish.
Repeat this process for the second board after unplugging the first one. Once both are flashed, you can use the Meshtastic CLI to configure the network. FYI takes a bit of time to flash so please be patient.
Step 3 – Set a Private Channel
To keep your mesh network secure and ensure only your nodes can communicate with each other, you’ll assign a custom channel name and a randomly generated PSK (pre-shared key). You’ll do this on one board and then sync the config to the other using a shared URL.
You can connect both boards to your computer at this point simultaneously.
On the first board (replace port accordingly):
meshtastic --port /dev/cu.usbserial-0001 --begin-edit
meshtastic --port /dev/cu.usbserial-0001 --ch-index 0 --ch-set name shillehtek
meshtastic --port /dev/cu.usbserial-0001 --ch-index 0 --ch-set psk random
meshtastic --port /dev/cu.usbserial-0001 --set lora.region US
meshtastic --port /dev/cu.usbserial-0001 --commit-edit
Get the generated channel URL:
meshtastic --port /dev/cu.usbserial-0001 --info | grep "Primary channel URL"
Will look something like this:
Primary channel URL:
https://meshtastic.org/e/#CjISIPj3EGnyJNApN2t04c86sxvhjdSRpIB-ar2Mhc4W6RUoGgpzaGlsbGVodGVrOg
On the second board:
meshtastic --port /dev/cu.usbserial-0002 --ch-set-url "https://meshtastic.org/e/#..."
meshtastic --port /dev/cu.usbserial-0002 --set lora.region US
meshtastic --port /dev/cu.usbserial-0002 --reboot
On the first board (restart one more time just to be sure all settings took effect):
meshtastic --port /dev/cu.usbserial-0001 --reboot
Both boards should now be on same secure mesh channel and able to receive signals from one another.
Step 4 – Test Mesh Communication
Separate the boards by at least 2–3 feet (yes, LoRa radios can get overwhelmed when too close). Then run on either board:
meshtastic --port /dev/cu.usbserial-0001 --sendtext "Hello from Node 1"
meshtastic --port /dev/cu.usbserial-0001 --nodes
You should now see the message received on the other board! Pretty cool. You can test how far you can send this, probably get a few miles of range in an open area.
Common Issues We Faced (and Fixed)
-
Stuck CLI commands: Use
/dev/cu.usbserial-*
instead of/dev/tty
on Mac to find the connected serial devices. -
Region not set: If
lora.region
isUNSET
, nodes won’t transmit. Always set it toUS
or your local region. - Too close? LoRa radios need some distance to function well — move them a few feet apart. I had to move them a few feet apart before working. Use a longer cable or you can even power one from another computer or separate power source.
-
Wrong PSK? Use
--ch-set-url
from one node to replicate exact channel config to others.
What’s Next?
Congrats you just made a low cost mesh network with LoRa modules and open source modules. LoRa is incredibly powerful technology, used in real life projects for long range, free, and secure communication. This opens a world of IoT projects you can tackle!
Here are some projects you can try after this:
- Send GPS location updates over the mesh
- Create a solar-powered LoRa repeater node
- Set up LoRa to MQTT bridge for remote telemetry
- Connect your phone to the network
Let me know if you want to see any of these by commenting on the YouTube channel!
If you're interested, hire me on UpWork and I’ll help you design and deploy a custom LoRa solution for your use case — from mesh messaging to off-grid sensor networks. Also, don’t forget to subscribe on YouTube to see these projects in action!
Built by ShillehTek — empowering developers and makers to do more with embedded systems.