Turn an Arduino Into a Quick & Easy LoRa Packet Sniffer

13,922

36

7

Introduction: Turn an Arduino Into a Quick & Easy LoRa Packet Sniffer

About: Hi... Greg Terrell here. I am the founder and CEO of LooUQ, an IoT technology company in Michigan. We frequently need to invent new things to test our products; when we create a test fixture that we think oth…

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: Step 1: Select Your Arduino

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: Step 2: Download the Radio Head Library

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: 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: Step 4: Analyze Your Network Traffic

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

Be the First to Share

    Recommendations

    • Digital Fabrication Student Design Challenge

      Digital Fabrication Student Design Challenge
    • Leather Challenge

      Leather Challenge
    • Build a Tool Contest

      Build a Tool Contest

    7 Comments

    0
    mohamadnourbader
    mohamadnourbader

    Question 11 months ago on Step 3

    Hello, thanks for this tutorial i have some points I want to know.
    1. i am using esp32 as an Arduino board does that work?
    2. i should set the frequency depending on the app freq or the lora board that is I using(rfm9x)?
    3. should I make any configuration for the lora device/sensor that I want to sniff hid pocket or just make it work normally

    0
    Greg Terrell
    Greg Terrell

    Answer 11 months ago

    - The esp32 should work, you will just need to adjust your pins. I can't offer specific advise on the esp32 as I have not used the chipset.
    - The frequency is set according to the LoRa frequencies for your region. In the US that is 915MHz, many other countries use 868MHz. Google "Frequency bands by country" for references.
    - As long as the LoRa contents are not encrypted (The Things Network) you should be able to see the payloads. My post was used to test a local, private LoRa link where I could turn the payload encryption on\off. The sniffer software will see the entire radio packet returned by hardware.

    If you get stuck on your efforts, there is an option on Tindie that works well (at least for Windows workstations).
    https://www.tindie.com/products/steven/lostik-open...

    There
    Good luck with your project,
    Greg

    0
    maalmasri
    maalmasri

    Question 2 years ago on Introduction

    could i get more infos about how you connected the Boards together ?

    0
    Greg Terrell
    Greg Terrell

    Answer 2 years ago

    The board I used for the sniffer was an Adafruit Feather M0 with RFM95 LoRa Radio - 900MHz (product #3178). This internally connects the processor with the radio over SPI. Additionally reset=4, irq=3, cs=8 (# is the digital pin). Even though Adafruit is only shipping for "essential" needs because of COVID, there are other distributors such as Digikey, Mouser to consider.

    Good luck with your project,
    Greg

    0
    maalmasri
    maalmasri

    Reply 2 years ago

    thanks a lot!
    could you see the downlink traffic too ?

    0
    Greg Terrell
    Greg Terrell

    Reply 2 years ago

    That setup should see both directions. It is simply listening for any LoRa traffic. So if there are multiple talkers in range they will be intermingle too.

    0
    Swansong
    Swansong

    5 years ago

    Thanks for sharing :)