Turn an Arduino Into a Quick & Easy LoRa Packet Sniffer

by Greg Terrell in Circuits > Wireless

20567 Views, 39 Favorites, 0 Comments

Turn an Arduino Into a Quick & Easy LoRa Packet Sniffer

IMG_0335.JPG

If you work with communications for a while, you will reach a point where you realize that if you could get an outside perspective that would really help your debugging efforts. That is what this project is all about, turning an Arduino into a LoRa radio packet sniffer. With this in your toolbox you will be able to see the traffic between two or more LoRa radio nodes, which will help you troubleshoot the applications your developing as they communicate across a LoRa network.

By example: while developing our LoRa Gateway product, we wanted to more easily examine the effects of different type of performance tuning changes. We could use traditional "programming" tools such as breakpoints or debug\print statements, but these techniques have side affects and alter the system being adjusted by their presence. By using a "network probe" or "packet sniffer" such as shown here, you can monitor the device communications without changing the software performing the communications. The packet sniffer approach has been used for years, this project is just an inexpensive approach to add to your toolkit with parts you might already own.

For the system I wish to test, I am using a Raspberry PI 3 running gateway software and an Adafruit Feather M0 with RFM95 LoRa Radio (900MHz for North America) as the "end-node" sensor device. As I make adjustments to the gateway or device software, the LoRa packet sniffer allows me to see timing (using millis()) and contents of LoRa packets traversing the network.

Step 1: Select Your Arduino

IMG_0338.JPG
IMG_0336.JPG

I am using the Adafruit Feather M0 with RFM95 LoRa Radio as the basis for my packet sniffer. I choose this device for the project because everything I needed are on one circuit board. But, this project can be built with other Arduino\Arduino-like development boards. In the INO file we have included GPIO settings for other boards (thank you Adafruit); this includes the Feather M0 with integrated LoRa radio, Feather 32u4 with integrated LoRa radio, Arduino with a Adafruit breakout board or the Feather 32u4, Feather M0 or Teensy 3.x using the LoRa Feather Wing.

Make sure if you purchase a new LoRa device that you select the correct frequency band; choose the correct frequency for your geographic region and to match your existing devices that you wish to monitor.

Adafruit Feather M0 with RFM95 LoRa Radio

Adafruit LoRa RFM95 Breakout

Adafruit LoRa Radio FeatherWing - RFM95W 900 MHz

Step 2: Download the Radio Head Library

2017-06-20_16-03-00.png

You will need two pieces of code from the Internet to build this project, both are open-source and free.

  1. RadioHead RF Library (AirSpacye Ltd.)
  2. The INO for the packet sniffer application.

AirSpayce has developed the RadioHead Packet Radio library for embedded microprocessors that supports the RF95 radio (from HopeRF). This is an excellent library that supports the Arduino type boards mentioned in Step 1. It is open-source, licensed under GPL Version 2. You most likely are already using the Radio Head library in your project, but if you don't already have it, download the library from the Radio Head website.

Radio Head library site

Once downloaded put the entire contents of the Radio Head (RH) library (zip) in a folder below your Arduino IDE libraries folder.

Step 3: Copy the Code Into a New INO

You can download the sniffer sketch from the LooUQ GitHub site. The repository link is

https://github.com/LooUQ/Arduino-LoRa-Sniffer

Once downloaded and copied into a sketch folder, you will want to review and\or update some settings in the sketch for your own needs (at about line 18).

  • Output mode: verbose or delimited
  • If you are set for delimited output, you may want to change the delimiter character (default is '~')

/* Define your desired output format here */
OutputMode mode = delimited;
#define DELIMETER_CHAR '~'
/* end output format defintion */

  • The default frequency for the radio is set to 915 MHz, you may need to change this based on your location and the frequency of your other radios (at about line 65).

// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 915.0

Step 4: Analyze Your Network Traffic

2017-06-20_15-41-03.png
2017-06-20_15-42-16.png

Start your network...

With your LoRa network running, start the sniffer sketch and start collecting.

For save to disk, you can use any terminal application you like, but not the Arduino IDE Serial Monitor. Unfortunately, the Arduino IDE Serial Monitor is not currently capable of saving the serial port stream. Internally we use and can recommend Tera Term; Tera Term has numerous features: including automatic serial port detection and write to disk.

Tera Term (Wikipedia)

Delimited View (above)

Verbose View (below)

If you are using delimited, you can view your network trace offline using Microsoft Excel, Apache OpenOffice or Google Sheets.

Hope this helps someone debug something faster.

Greg @ LooUQ