Skip to content

Lupin3000/DFRobot_LoRaWAN_NodeModules

Repository files navigation

Gravity: LoRaWAN Node Module

Static Static

You can find the details about LoRaWAN Node Modules on the DFRobot Wiki page. The original CPP drivers and Arduino examples are available on DFRobots GitHub repository.

Preparation

# clone GitHub project
$ git clone https://github.com/Lupin3000/DFRobot_LoRaWAN_NodeModules.git

# change into cloned project directory
$ cd DFRobot_LoRaWAN_NodeModules/

# create Python virtualenv (optional)
$ python3 -m venv .venv

# activate Python virtualenv (macOS & Linux)
$ source .venv/bin/activate

# activate Python virtualenv (Windows)
$ .\.venv\Scripts\activate

# update pip (optional)
(.venv) $ pip3 install -U pip

Hardware

Follow the provided links to purchase the LoRaWAN Node Modules.

Ensure that the protocol switch is set to UART (for Python Serial and MicroPython UART) on the LoRaWAN Node module.

i2c_uart_switch.jpg

Find USB devices

Here you can find the examples for commands to find the USB devices on your system.

# Linux
$ ls /dev/ttyUSB*

# macOS
$ ls /dev/cu.usb*

# Windows
$ Get-WMIObject Win32_SerialPort | Select-Object DeviceID, Name

Python (serial)

The Python serial module supports LoRa and LoRaWAN modes for EU868/US915/CN470.

Quick Installation

# install required Python dependencies
(.venv) $ pip3 install -r serial_requirements.txt

# show packages (optional)
(.venv) $ pip3 freeze

Serial P2P example files are located in the example_serial_*.py files.

Project
├── conf
│   ├── lora_configuration.py
│   └── serial_configuration.py
├── lib
│   └── serial_module_driver.py
├── example_serial_receive.py
└── example_serial_send.py

Run LoRa (P2P) serial example

serial connection example

The picture shows the usage of CH340 USB to TTL converters for each LoRaWAN Node module.

Before running the examples to send and receive data. Ensure the configuration settings meet your requirements! Therefor, adapt files conf/lora_configuration.py and conf/serial_configuration.py.

# start serial receive
(.venv) $ python3 example_serial_receive.py

Received payload: Hello (0)
Received payload: Hello (1)
Received payload: Hello (2)
Received payload: Hello (3)
Received payload: Hello (4)
[INFO] Closing serial connection.
[INFO] Exiting...
[INFO] Closing application...

# start serial send
(.venv) $ python3 example_serial_send.py

Sending payload: Hello (0)
Sending payload: Hello (1)
Sending payload: Hello (2)
Sending payload: Hello (3)
Sending payload: Hello (4)
[INFO] Closing application...

MicroPython (UART)

The MicroPython UART module supports LoRa and LoRaWAN modes for EU868/US915/CN470.

Quick Installation

# install required MicroPython dependencies
(.venv) $ pip3 install -r uart_requirements.txt

# show packages (optional)
(.venv) $ pip3 freeze

If MicroPython is not flashed on the ESP device, download the latest firmware from MicroPython. The next step is to flash the MicroPython firmware on the ESP device via the esptool.

Note: In case you are not familiar with command line tools like esptool, or you don't know what firmware you need, try MicroPython-Firmware-Studio. The tool provides a graphical user interface to flash MicroPython firmware on the ESP device.

After that, use rshell to connect to the ESP device and upload the required directories and files. Rename the P2P example files like example_uart_*.py to main.py!

ESP
├── boot.py
├── conf
│   ├── lora_configuration.py
│   └── uart_configuration.py
├── lib
│   └── uart_module_driver.py
└── main.py

Run LoRa (P2P) UART example

uart_connection.jpg

The picture shows the usage of ESP32 NodeMCU with LoRaWAN Node module.

Before running the examples to send and receive data. Ensure the configuration settings meet your requirements! Therefor, adapt files conf/lora_configuration.py and conf/uart_configuration.py.

# receive LoRa payload (example_uart_receive.py)

Received payload: Hello (0)
Received payload: Hello (1)
Received payload: Hello (2)
Received payload: Hello (3)
Received payload: Hello (4)

# send LoRa payload (example_uart_send.py)

Sending payload: Hello (0)
Sending payload: Hello (1)
Sending payload: Hello (2)
Sending payload: Hello (3)
Sending payload: Hello (4)

API Reference

Here you can find the API reference for the Python and MicroPython modules.

Important

The code is provided without any guarantee. Use it at your own risk. The developer assumes no liability for any damage or legal consequences resulting from using the software. Please ensure compliance with all applicable laws and regulations when using this software.

About

Python/MicroPython drivers for DFRobot LoRaWAN Node Module

Topics

Resources

License

Stars

Watchers

Forks

Languages