I’ve been itching to work on some hardware projects lately and kept seeing ESP32-related things pop up on Reddit. In particular, I was coming across a lot of LoRa projects, and then started down a rabbit hole.
LoRa (from long range) is a proprietary radio technology that is owned by Semtech. It is designed for long-range (e.g., 10km), low-bandwidth (i.e., measured in Kbps), low-power communication, primarily for internet of things (IoT) networks.
LoRa defines the physical layer that controls how the radio signals are modulated. Specifically, LoRa uses chirp spread spectrum (CSS) to encode information. You can view more about LoRa and CSS in this video.
LoRa operates in a license-free, sub-gigahertz frequency band (i.e., under 1GHz or 1000MHz), but each frequency varies from region to region due to regulatory requirements. If you’re buying a LoRa device, make sure you pick one tuned to the correct frequency band for your region.
- China - 470-510MHz and 779-787MHz
- Europe - 863–870MHz (typically 868MHz)
- India - 865–867 MHz (typically 865MHz)
- Japan - 920-923MHz
- USA - 902–928 MHz (typically 915MHz)
- South America - 915–928 MHz (typically 915 or 923MHz)
LoRa tries to bridge the gap between current communication technologies, like WiFi, Bluetooth, and cellular (4G/5G).
LoRa is useful for long-range, low-bandwidth, low-power communication, which is perfect for IoT devices. Some examples include:
- a water sensor in a well in a remote location
- a factory with hundreds of smoke alarms that all need to communicate
- a large nature preserve trying to track animal migration
- a natural gas provider needing to monitor each customer’s meter for usage
- a weather station that only occasionally needs to transmit information
LoRa and LoRaWAN
LoRaWAN builds on top of LoRa to define the communication protocol and system architecture.
Meshtastic builds on LoRa (not LoraWAN) to produce a decentralized mesh network. Features include:
- Text-based, encrypted communication
- No phone required (e.g., you can use a computer with the right hardware), but there are iOS and Android applications
- Great battery life
- Optional GPS location sharing
- Open-source software
Unlike the traditional cellular network, each end-user device (e.g., phone, laptop, etc…) connects to a LoRa radio running Meshtastic, and all LoRa radios running Meshtastic can mesh together. Messages are relayed through LoRa radios until they reach their destination.
Meshtastic firmware is available for a handful of devices, but I was looking for:
- 915MHz support (because I’m in the US)
- WiFi and Bluetooth (this meant the microcontroller needed to be an ESP32 instead of the nRF52840, which lacks WiFi)
- GPS (optional)
I was also looking for the newer SX1262 chip instead of the older SX1276 (source here).
This left me with the following options:
- Heltec WiFi LoRa 32 (V3) - No GPS
- Heltec Wireless Stick Lite (V3) - No GPS or display
- LILYGO TTGO T-Beam v1.1 - MicroUSB, older NEO-6M GPS, Semtech SX1276
- LILYGO TTGO T-Beam v1.1 with NEO-M8N - MicroUSB, newer NEO-M8N, Semtech SX1276
- LILYGO TTGO T-Beam v1.1 with NEO-M8N and SX1262 - MicroUSB, newer NEO-M8N, Semtech SX1262
- LILYGO® TTGO Lora T3S3-V1.0 - No GPS
In the end, I purchased two of each of the following:
- LILYGO® TTGO Lora T3S3-V1.0 (the SX1262 915MHz version, this took about 2 weeks to arrive)
- 3D printed case
- 915MHz antenna (with SMA male connector)
First, I made sure the device was showing up. This showed that my device was using
mkdir -p ~/Downloads/lora cd ~/Downloads/lora python3 -m venv venv source venv/bin/activate pip install esptool esptool.py chip_id
I downloaded the latest beta firmware. At the time of this writing, this was
wget https://github.com/meshtastic/firmware/releases/download/v220.127.116.11ec624d/firmware-18.104.22.168ec624d.zip unzip firmware-22.214.171.124ec624d.zip
This is the command I used to flash. Don’t blindly copy/paste this, because the firmware is specific for the LILYGO® TTGO Lora T3S3-V1.0.
./device-install.sh -p /dev/ttyACM0 -f firmware-tlora-t3s3-v1-126.96.36.199ec624d.bin
After manually restarting the device, I was greeted by the Meshtastic logo. I repeated the flashing process for the other device.
Meshtastic offers a variety of apps, including Apple and Android apps, as well as a Python app, and even a web client (either served directly from the device’s local web server, or from your browser via the Web Serial protocol).
I paired one device to the Android app and another to my browser via the Web Serial protocol.
Once paired and connected, I made sure to set the region to
US, since I wanted to be on the 915MHz frequency. I didn’t change the pre-shared key, so both devices were able to see one another right away and communicate.
Here, you can see the messages on the web app.
Here, you can see the messages on the Android app.
To be clear, these devices are NOT communicating via text (SMS), but instead over LoRa, completely off-grid! 🤯
I’m still waiting on the 3D printed cases to arrive, but I’m going to try to head outside and do some range tests with these devices. Very cool!