Manage cookies

We use cookies to improve our services. Read more about how we use cookies and how you can refuse them.

The necessary cookies help to make the website work properly.

Anonymous statistical cookies help to understand how visitors use the website.

  • LoRa/LoRaWAN, MicroPython
    3 min | 41536

    #MicroPython: ESP32 sending data using LoRa

    LoRa/LoRaWAN, MicroPython | 3 min | 41536


    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:

    1. Important: Attach the antenna before supplying the boards. If the antenna is not connected, this may damage the LoRa chip.
    2. Clone the uPyLora repository.
    3. 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)
    4. 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.


    Comments

    Empty