💾 Archived View for vy.binarylab.eu › gemlog › 2018-01-24-lora-rf95.gmi captured on 2023-01-29 at 15:34:05. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

Long Range Radios Linux/macOS Part 2 - Adafruit Feather m0 RFM96 Lora Radio

After previously playing around with the e32-ttl-100 modules, this time the focus is on microcontroller boards that include a lora transceiver. These devices are very small, the library for radio access seems to be quite stable and it already has support for packet transmission! So not only is SLIP encoding obsolete here but the maximum packet size is also significantly larger at over 250 bytes! The downside? You have to write your code in C/C++ for a microcontroller! This is something completely different than developing for Linux systems such as a Raspberry Pi or even an OpenWRT-based router!

Picture: Adafruit Feather m0 lora with ghetto-style wire antenna

The solution? Use the integrated serial port on the microcontroller to simulate a modem. Therefore, only the low level stuff has to be developed for the microcontroller and higher level communication stuff can be handled on other devices! In my case, I prototyped all this on an Adafruit Feather m0 lora module as shown in the picture above.

Adafruit Feather m0 lora module

The rf95modem firmware is available open source and can be easily build using PlatformIO. Currently, only some of the RFM95 parameters can be manipulated through the serial interface and one can only send and receive data frames via the serial port. The "modem" is controlled through AT commands similar to classic dial-up modems.

rf95modem firmware

PlatformIO

Here is a list of currently implemented commands:

AT+HELP             Print this usage information.
AT+TX=<hexdata>     Send binary data.
AT+RX=<0|1>         Turn receiving on (1) or off (2).
AT+INFO             Output status information.
AT+MODE=<NUM>       Set modem config:
                    0 - medium range (default)
                     Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on.
                    1 - fast+short range
                     Bw = 500 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on.
                    2 - slow+long range
                     Bw = 31.25 kHz, Cr = 4/8, Sf = 512chips/symbol, CRC on.
                    3 - slow+long range
                     Bw = 125 kHz, Cr = 4/8, Sf = 4096chips/symbol, CRC on.

This makes sending raw data really easy:

AT+TX=414141

Beware, overlong packets might be a problem since the radio drivers might not always give correct numbers for maximum message length!

Receiving this data on another module is just as easy. First, the receive listener must be activated:

AT+RX=1

And the for each incoming transmission a line similar to the following is printed to the serial line:

+RX 3,414141,-15,8

This means that 3 bytes, encoded as a HEX string, were received. RSSI for this packet was -15 and SNR was 8.

Furthermore, one can display various status information about the current configuration using the `AT+INFO` command:

status info:
firmware:      0.1

modem config:  medium range
max pkt size:  251
frequency:     433.00
rx listener:   1

rx bad:        0
rx good:       0
tx good:       3

This makes it really easy to tap into machine-to-machine networks using rf95-family based lora chips from any mac or linux computer. Due to the fact that I only have simple wire antennas attached, I have not made any real range tests yet. Once my uFL connectors and antennas from aliexpress get here, I will do some more serious experiments.