- Table of contentShow
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.
I was interested in using this technology and I found that WeMos has a board that contains an ESP32, the LoRa chip SX1276 and a SSD1306 display (check the hardware & software section).
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
(*) be careful with TTGO v2.1.6 some boards has a risk of fire, if you charge a battery.DIY: uPyLora
This tutorial is only about LoRa. If you are looking for LoRaWAN on MicroPython, follow the tutorial from this link: Tutorial: ESP32 running MicroPython sends data over LoRaWAN.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
uPyLora
repository. Edit the
main.py
file 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:Sender
import LoRaSender ... LoRaSender.send(lora)
Receiver
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.
We use cookies to improve our services. Read more about how we use cookies and how you can refuse them.
Hugh 11.16.2018
Nice article. I have just got a pair of TTGO LoRa32 V2.0 boards and I am trying to get the LoRaSender.py working on one (I have modified the SSD1306 pins so that the display works ok) However I don't seem to be able to broadcast any messages. Looking at controller_esp32.py I notice that PIN_ID_SCK and PIN_ID_FOR_LORA_DIO0 are both set to 5. Is this correct? Looking at the schematics it seems that LORA_IRQ (PIN_ID_FOR_LORA_DIO0) should be 26. I have tried this but still not working. Any ideas? Thanks very much Hugh
Martin Korinek 01.08.2019
Great article! I am looking for a way how to send data using micropython + LoRa device (Wemos or another) to TTN (thethingsnetwork). Has it been done? Is there some library for that purpose?
Thanks in advance Martin
Ken 02.17.2019
I'am new tho micropython and can't get your code to run. I get this error. What do I need to do? Thanks Ken Traceback (most recent call last): File "/home/ken/uPyLora-master/main.py", line 2, in File "LoRaPingPong.py", line 3, in ImportError: no module named 'uPySensors'
sara 04.11.2021
I needed to perform some little changes: Like I had to change the path for the python modules, since the upload on VSC puts all files on the uPyLoRaWAN directory. Also had to change the config.sample.py file name to config.py. I am not sure if these were expected to be performed or if I am missing something.