LMIC transmit example for NAmote-72 with GPS

Dependencies:   lib_gps lib_mpl3115a2 lmic_MOTE_L152RC mbed

Deprecated and replaced with

Import programLoRaWAN-NAMote72-Application-Demo

Demonstration of Class-A LoRaWAN device using NAMote-72

LoRaWAN Network Configuration (in Config.h)

For Over the Air (OTA) activation of an End-Device, it must be configured with the following parameters:

  1. DEVEUI (8 Bytes) : Fist 3 Bytes is the Organizationally Unique Identifier (OUI) followed by 5 bytes of unique ID.
  2. APPEUI (8 Bytes)
  3. APPKey (or DEVKEY) (16 Bytes) The parameters can be entered as shown in the figure below /media/uploads/ubhat/nwkconfig.png

LoRaWAN Transmission Configuration (in Config.h)

  • Inter-Frame Delay : One can change the delay between each frame transmission using MS_DELAY_NEXT_TX It is advisable that MS_DELAY_NEXT_TX is greater than or equal to 3sec. /media/uploads/ubhat/txtiming.png
  • Payload Length : The lenght of the payload (in bytes) to be transmitted can be configured using PAYLOAD_LENGTH /media/uploads/ubhat/payload.png
  • Data Rate : The data rate can be configured as per LoRaWAN specification using the paramter FIXED_DR /media/uploads/ubhat/datarate.png
  • Channel Configuration : In the case where the End-Device is transmitting over frequencies corresponding to a block of 8 channels, the block can be specified using CHNL_HYBRID. The value 0 corresponds to Block A, 1 corresponds to Block B and so on. /media/uploads/ubhat/hybrid.png When the End-Device transmits over more than 50 channels, CHNL_HYBRID needs to be commented out /media/uploads/ubhat/frequencyhopping.png
  • Transmit Power : The power of the data to be transmitted can be configured using the parameter FIXED_TX_POWER. The maximum transmit power allowed is as per FCC regulation, depending upon the mode of transmission. /media/uploads/ubhat/txpower.png

Serial Terminal Display

By using a serial port connection using applications such as teraterm or putty, one can view the status of the End-Device. Once the End-Device Joins the network, transmission parameters such as payload data, transmit power, battery level etc. are displayed on the terminal.

/media/uploads/ubhat/teraterm.png

Default Application Payload

This application defaults to sending uplink data to logical port 5. The application payload consists of: /media/uploads/jknapp_smtc/payload.png

Sample Application Payload Calculation for Longitude/Latitude

Payload => 00 19 F6 352BBA A94C20 FFFF

Temperature Calculation

19H => 2510

Temp = 25/2 = 12.5 oC

Battery Level

FFH => 100 %

F6H => 96.5 %

Longitude Calculation

longitude = A94C20H => 1109507210

longitudinal coordinate = -360 + (longitude10 x 180/(223))

longitudinal coordinate = -121.93

Latitude Calculation

latitude = 352BBAH = 348460210

latitude coordinate = (latitude10 x 90/(223-1))

latitude coordinate = 37.39

Files at this revision

API Documentation at this revision

Comitter:
dudmuck
Date:
Sat Jul 18 00:21:10 2015 +0000
Parent:
3:d81e4a63fb2e
Child:
5:6244f45b15f2
Commit message:
shorted TX delay to 400ms

Changed in this revision

config.h Show annotated file Show diff for this revision Revisions of this file
lmic_MOTE_L152RC.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/config.h	Fri Jul 17 21:11:02 2015 +0000
+++ b/config.h	Sat Jul 18 00:21:10 2015 +0000
@@ -2,4 +2,4 @@
 
 #define CFG_sx1272_radio
 
-//#define CHNL_HYBRID
\ No newline at end of file
+#define CHNL_HYBRID
\ No newline at end of file
--- a/lmic_MOTE_L152RC.lib	Fri Jul 17 21:11:02 2015 +0000
+++ b/lmic_MOTE_L152RC.lib	Sat Jul 18 00:21:10 2015 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/Semtech/code/lmic_MOTE_L152RC/#e4ba433f0ac1
+https://developer.mbed.org/teams/Semtech/code/lmic_MOTE_L152RC/#dfc048cda33f
--- a/main.cpp	Fri Jul 17 21:11:02 2015 +0000
+++ b/main.cpp	Sat Jul 18 00:21:10 2015 +0000
@@ -19,8 +19,8 @@
 #include "debug.h"
 
 
-#define SENET_F
-//#define SMTC
+//#define SENET_F
+#define SMTC
 
 typedef enum {
     MOTE_NONE = 0,
@@ -40,9 +40,9 @@
 // DevEUI and Keys defined by Activation type //
 #define APP_DATA_SIZE               11
 #define APP_ACK                     0
-#define DELAY_NEXT_TX               10
+#define MS_DELAY_NEXT_TX               400
 #ifdef SMTC
-#define OVER_THE_AIR_ACTIVATION     0
+#define OVER_THE_AIR_ACTIVATION     1 //0
 #else
 #define OVER_THE_AIR_ACTIVATION     1
 #endif /* SMTC */
@@ -82,15 +82,17 @@
 #ifdef SMTC
 // Semtech Activation (v1.x server)
 // application router ID (LSBF)
-static const u1_t APPEUI[8]  = { 0xAA, 0xCC, 0x11, 0x00, 0xCC, 0xEE, 0x77, 0xEE };
+static const u1_t APPEUI[8]  = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
 
 // unique device ID (LSBF)
-static const u1_t DEVEUI[8]  = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF };
+//static const u1_t DEVEUI[8]  = { 0x20, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x25, 0x00 };
+static const u1_t DEVEUI[8]  = { 0x34, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x25, 0x00 };
+//static const u1_t DEVEUI[8]  = { 0x35, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x25, 0x00 };
 
 // device-specific AES key (derived from device EUI)
-static const u1_t DEVKEY[16] = { 0xAB, 0x89, 0xEF, 0xCD, 0x23, 0x01, 0x67, 0x45, 0x54, 0x76, 0x10, 0x32, 0xDC, 0xFE, 0x98, 0xBA };
+static const u1_t DEVKEY[16] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff  };
 
-static uint8_t NwkSKey[] = 
+/*static uint8_t NwkSKey[] = 
 { 
     0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
     0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
@@ -100,7 +102,7 @@
 { 
     0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
     0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
-};
+};*/
 
 #endif /* SMTC */
 
@@ -267,6 +269,9 @@
     else
         LMIC.txpow_limit = 30;
 #endif /* !CHNL_HYBRID */
+
+    // test forcing:
+    LMIC.datarate = DR_SF10;    // force SF10
     
 }
 
@@ -306,7 +311,7 @@
             os_setTimedCallback( &rxLedJob, os_getTime() + ms2osticks(15), onRxLed );
         }
 tx:
-        os_setTimedCallback( &sendFrameJob, os_getTime() + sec2osticks(DELAY_NEXT_TX), onSendFrame ); // Change the Tx periodicity
+        os_setTimedCallback( &sendFrameJob, os_getTime() + ms2osticks(MS_DELAY_NEXT_TX), onSendFrame ); // Change the Tx periodicity
         //onSendFrame(NULL);
         
         // Blink Tx LED