Bjoerns-TB / M5Stack-COM-LoRaWAN-Network-Tester

MIT License
3 stars 0 forks source link

M5Stack-COM.LoRaWAN-Network-Tester

A LoRaWAN Network Tester based on the M5Stack for the COM.LoRaWAN module, compatible with TTN (The Things Network). Currently i am only supporting TTN V2, i am testing with The Things Stack (V3), but the node behaves very confusing (sending unwanted/untriggered Uplinks).

The AT command set of the module does not allow to perform a LinkCheckRequest. So in this version LCM and SSV mode are not integrated/possible. Currently i am testing a workarround with Node-RED, creating a new downlink with the needed informations.

To use the new SetDR feature, you have to update the CubeCell module. In short you have to flash the LoRa -> AT_Command example ont the CubeCell module. Don't forget to set the region. Instructions for Update COM.LoRaWAN (Only in german). ACK won't work past SF8 because TTN will send on RX2 frequency an SF9.

Version for LoRa 868 Module

Version for LoRaWAN Module

Setup

The tester is designed to work with the following hardware:

Required Libraries!

Installation and Configuration

Upload this sketch to your M5 using the Arduino IDE. M5Stack Fire users have to disable PSRAM, because it will interfer with UART2. UART2 with GPIO 16 and 17 willbe used for the GPS module.

USe the mini switch on dem COM.X module to set RX to 13 an TX to 5.

Setup Image

By commenting out #define M5go it is possible to disable the M5GO Base. This will disable all NeoPixel related code and features. By commenting out #define M5gps ist is possible to disable the M5GPS module. This will disable all GPS related code and features.

Change the your TTN keys under //ABP and //OTAA inside the initlora() function from the networktester.ino file. If you want yo use OTAA you have to register a second device for your application.

Payload Decoder for TTN (V2) (also compatible with TTN Mapper integration):

function Decoder(b, port) {

  var lat = (b[0] | b[1]<<8 | b[2]<<16 | (b[2] & 0x80 ? 0xFF<<24 : 0)) / 10000;
  var lon = (b[3] | b[4]<<8 | b[5]<<16 | (b[5] & 0x80 ? 0xFF<<24 : 0)) / 10000;
  var alt = (b[6] | b[7]<<8 | (b[7] & 0x80 ? 0xFF<<16 : 0)) / 100;
  var hdop = b[8] / 10;

  return {

      latitude: lat,
      longitude: lon,
      altitude: alt,
      hdop: hdop

  };
}

Payload Decoder for The Things Stack (V3) (experimental):

function decodeUplink(input) {
    var data = {};

  data.latitude = (input.bytes[0] | input.bytes[1]<<8 | input.bytes[2]<<16 | (input.bytes[2] & 0x80 ? 0xFF<<24 : 0)) / 10000;
  data.longitude = (input.bytes[3] | input.bytes[4]<<8 | input.bytes[5]<<16 | (input.bytes[5] & 0x80 ? 0xFF<<24 : 0)) / 10000;
  data.altitude = (input.bytes[6] | input.bytes[7]<<8 | (input.bytes[7] & 0x80 ? 0xFF<<16 : 0)) / 100;
  data.hdop = input.bytes[8] / 10;

        return {
        data: data,
        warnings: [],
        errors: []
    };
}

Instructions for Use

Menu

On boot you will be presented with the "Boot-Logo" followed by the first working mode. At the moment the tester has 5 modes to select:

You can move between menu items by pushing the button A.

Menu Image

NACK

(No Acknowladge)

"NACK" is a mode that utlises the current device settings to perform periodic transmissions. "NACK" mode is great for use with TTN Mapper.

NACK Image

By pushig button C the display and LEDs will be turned off. Pushing button C again will turn them on.

ACK

(Acknowladge)

"ACK" will perform the same test as NACK but it will request an ACK for every transmission. The RSSI and SNR values of the received packet will be shown on the display. By pushig button C the display and LEDs will be turned off. Pushing button C again will turn them on.

ACK Image

MAN

(Manual)

"MAN" will send a LoRaWAN packet with ACK by pushing button C.

MAN Image

LCM

(LinkCheckMode) - Currently only a teaser, code not implemented yet; Node-RED needed

"LCM" is a mode that will trigger a LinkCheckRequest, with the help from Node-RED. For this to work you will need a running instance of Node-RED using this Flow. Pushing button B will let you cycle through each spreadfactor. The request is triggered by button C. The Uplink data will be presented in te follwoing order: No of Gateways | RSSI | SNR

LCM Image

OTAA

(OverTheAirActivation)

"OTAA" enables the tester to perform OTAA-Joins. By selecting Join the tester will try to join the TTN Network. After an successful the the tester will start with periodic transmissions. You have the choice between transmission with or without ACK. The RSSI and SNR values of the received packet will be shown on the display. If there is no valid GPS fix, a packet can by manually send by pushing button B.

OTAA Image

SET

(Settings)

"SET" allows to change the transmission intervall in NACK or ACK mode. Possible settings are 15/30/45/60/120 seconds. Pressing button C will active the powersaving mode. The node will go to deep sleep and wakes up according to the transmission intervall. Sleep mode can only be stopped by resetting the devicde.

SET Image

Notes

Known Bugs/Limitations

Accesories

Changelog

ToDo