MicroPython | 3 min | 3003
LoRa (Long Range) is a patented digital wireless data communication technology. It was developed by Cycleo of Grenoble in France and then acquired by Semtech in 2012. Semtech defines the Lora Technology "as the DNA of IoT, which connects sensors to the Cloud and enables real-time communication of data and analytics that can be utilized to enhance efficiency and productivity".
To sum up, LoRa is a wireless data communication technology that enables very-long-range transmissions (more than 10 km in rural areas) with low power consumption. It uses license-free sub-gigahertz radio frequency bands as the 169 MHz, 433 MHz, 868 MHz for Europe and 915 MHz for North America. The technology can be divided in two parts:
- LoRa: the physical layer,
- LoRaWAN (Long Range Wide Area Network): the upper layers.
Surely, you've heard of Sigfox. You can find the differences netween LoRa and Sigfox here.
Pycom offers also two models of board that support LoRa: the FiPy and the LoPy4, but the prices were outside from my budget, considering that I needed to buy two boards to test the communication. If you want to go to production, may be you should consider using the Pycom boards because they don't only offer more communication possibilities (FiPy -> LTE, LoRa, Sigfox, WiFi, BLE) but also have an OEM version that you can easily integrate in your solution. Additionally, the MicroPython repository for Pycom (FiPy and LoPy4) contains the LoRa libraries. That means, you don't need my MicroPython classes! But, if you want to test LoRa and you have a low budget, check the following hardware & software list:
Hardware & Software
Wemos® TTGO LORA32 v1.0 x 1 Wemos® TTGO LORA32 v2.0 x 1 Wemos® TTGO LORA32 v2.1.6 (*) x 1 MicroPython Tutorial x 1 uPyLoRa x 1(*) be careful with TTGO v2.1.6 some boards has a risk of fire, if you charge a battery.
The uPyLora code is basically based on: Wei1234c GitHub. I cleaned the project and made it compatible with the Wemos® TTGO LORA32 868/915Mhz board. Minor code changes has to be done for compatibilities with the TTGO v2.0/2.1.6 (check the comment section!).
There are two modes that you can test with the following code:
- Ping-pong: sends ping-pong messages between the nodes (bidirectional communication)
- Sender or receiver: unidirectional communication between the nodes.
If you've not installed MicroPython on the ESP32 and you don't have any idea how to do that, click on the MicroPython Tutorial. Otherwise, follow the steps:
- Important: Attach the antenna before supplying the boards. If the antenna is not connected, this may damage the LoRa chip.
- Clone the
main.pyfile to activate the mode (default: ping pong). If you want to use the sender or receiver mode, uncomment the corresponding lines for the sender and receiver and comment the ping-pong lines:
import LoRaSender ... LoRaSender.send(lora)
import LoRaReceiver ... LoRaReceiver.receive(lora)
- Upload the code using atom.io, and reset the boards if needed.
uPyBikeTracker: Coming soon
I'm developing a bike tracker using these boards. I'll write an article soon, but you can follow the project on GitHub: uPyBikeTracker. I've programed the bike node using MicroPython (it is almost done!) and I'll program the receiver node using Zerynth (I've not tested it yet if it's compatible). Zerynth allows me to send data directly to the Google Cloud Platform (GCP), where I want to make some data processing.