Difference between revisions of "LoRaWAN"

From wiki.bastelbude.grade.de
Jump to: navigation, search
(ttnmapper.org)
(gateways)
 
(7 intermediate revisions by the same user not shown)
Line 8: Line 8:
 
=== devices ===
 
=== devices ===
 
* https://www.dragino.com/products/lora-lorawan-end-node/item/156-lt-22222-l.html
 
* https://www.dragino.com/products/lora-lorawan-end-node/item/156-lt-22222-l.html
 +
* https://heltec-automation-docs.readthedocs.io/en/latest/cubecell/index.html
 +
** http://community.heltec.cn/t/htcc-ab02s-lorawan-gps-and-lowpower-example/2684
 +
** https://github.com/HelTecAutomation/CubeCell-Arduino/blob/master/libraries/LoRa/examples/LoRaWAN/LoRaWAN_Sensors/LoRaWan_OnBoardGPS_Air530Z/LoRaWan_OnBoardGPS_Air530Z.ino
 +
 
=== gateways ===
 
=== gateways ===
 
* https://mikrotik.com/product/ltap_lr8_lte_kit
 
* https://mikrotik.com/product/ltap_lr8_lte_kit
 
** https://mikrotik.com/product/lora_antenna_kit
 
** https://mikrotik.com/product/lora_antenna_kit
 +
** you might need to istall RouterOS/MMIPS/Extra packages  (lora + gps) first
 +
** LTE-SIM goes slot-2 only
 +
 +
=== ttn ===
 +
==== Applications > [device lt-22222-l] > Payload Formats > decoder ====
 +
<pre>
 +
function Decoder(bytes, port) {
 +
  var hardware= (bytes[10] & 0xC0)>>6;
 +
  var mode0= bytes[10] & 0xff;
 +
  var mode= bytes[10] & 0x3f;
 +
  var decode = {};
 +
 
 +
  if(hardware=='0')
 +
  {
 +
    decode.Hardware_mode="LT33222";
 +
    decode.DO3_status=(bytes[8] &0x04)? "L":"H";
 +
    if(mode0=='1')
 +
    {
 +
    decode.DI3_status= (bytes[8] &0x20)?"H":"L";
 +
    }
 +
  }
 +
  else if(hardware=='1')
 +
  {
 +
    decode.Hardware_mode= "LT22222";
 +
  }
 +
 
 +
  if(mode!=6)
 +
  {
 +
    decode.DO1_status= (bytes[8] &0x01)? "L":"H";
 +
    decode.DO2_status= (bytes[8] &0x02)? "L":"H";
 +
    decode.RO1_status= (bytes[8] &0x80)? "ON":"OFF";
 +
    decode.RO2_status= (bytes[8] &0x40)? "ON":"OFF";
 +
    if(mode!=1)
 +
    {
 +
      if(mode!=5)
 +
      {
 +
      decode.Count1_times= (bytes[0]<<24 | bytes[1]<<16 | bytes[2]<<8 | bytes[3]);
 +
      }
 +
      decode.First_status= (bytes[8] &0x20)? "Yes":"No";
 +
    }
 +
  }
 +
 
 +
  if(mode=='1')
 +
  {
 +
    decode.Work_mode= "2ACI+2AVI";
 +
    decode.AVI1_V= parseFloat(((bytes[0]<<24>>16 | bytes[1])/1000).toFixed(3));
 +
    decode.AVI2_V= parseFloat(((bytes[2]<<24>>16 | bytes[3])/1000).toFixed(3));
 +
    decode.ACI1_mA= parseFloat(((bytes[4]<<24>>16 | bytes[5])/1000).toFixed(3));
 +
    decode.ACI2_mA= parseFloat(((bytes[6]<<24>>16 | bytes[7])/1000).toFixed(3));
 +
    decode.DI1_status= (bytes[8] &0x08)? "H":"L";
 +
    decode.DI2_status= (bytes[8] &0x10)? "H":"L"
 +
  }
 +
  else if(mode=='2')
 +
  {
 +
    decode.Work_mode= "Count mode 1";
 +
    decode.Count2_times= (bytes[4]<<24 | bytes[5]<<16 | bytes[6]<<8 | bytes[7]);
 +
  }
 +
  else if(mode=='3')
 +
  {
 +
    decode.Work_mode= "2ACI+1Count";
 +
    decode.ACI1_mA= parseFloat(((bytes[4]<<24>>16 | bytes[5])/1000).toFixed(3));
 +
    decode.ACI2_mA= parseFloat(((bytes[6]<<24>>16 | bytes[7])/1000).toFixed(3));
 +
  }
 +
  else if(mode=='4')
 +
  {
 +
    decode.Work_mode= "Count mode 2";
 +
    decode.Acount_times= (bytes[4]<<24 | bytes[5]<<16 | bytes[6]<<8 | bytes[7]);
 +
  }
 +
  else if(mode=='5')
 +
  {
 +
    decode.Work_mode= " 1ACI+2AVI+1Count";
 +
    decode.AVI1_V= parseFloat(((bytes[0]<<24>>16 | bytes[1])/1000).toFixed(3));
 +
    decode.AVI2_V= parseFloat(((bytes[2]<<24>>16 | bytes[3])/1000).toFixed(3));
 +
    decode.ACI1_mA= parseFloat(((bytes[4]<<24>>16 | bytes[5])/1000).toFixed(3));
 +
    decode.Count1_times= bytes[6]<<8 | bytes[7];
 +
  }
 +
  else if(mode=='6')
 +
  {
 +
    decode.Work_mode= "Exit mode";
 +
    decode.Mode_status= bytes[9] ? "True":"False";
 +
    decode.AV1L_flag= (bytes[0] &0x80)? "True":"False";
 +
    decode.AV1H_flag= (bytes[0] &0x40)? "True":"False";
 +
    decode.AV2L_flag= (bytes[0] &0x20)? "True":"False";
 +
    decode.AV2H_flag= (bytes[0] &0x10)? "True":"False"; 
 +
    decode.AC1L_flag= (bytes[0] &0x08)? "True":"False";
 +
    decode.AC1H_flag= (bytes[0] &0x04)? "True":"False";
 +
    decode.AC2L_flag= (bytes[0] &0x02)? "True":"False";
 +
    decode.AC2H_flag= (bytes[0] &0x01)? "True":"False"; 
 +
    decode.AV1L_status= (bytes[1] &0x80)? "True":"False";
 +
    decode.AV1H_status= (bytes[1] &0x40)? "True":"False";
 +
    decode.AV2L_status= (bytes[1] &0x20)? "True":"False";
 +
    decode.AV2H_status= (bytes[1] &0x10)? "True":"False"; 
 +
    decode.AC1L_status= (bytes[1] &0x08)? "True":"False";
 +
    decode.AC1H_status= (bytes[1] &0x04)? "True":"False";
 +
    decode.AC2L_status= (bytes[1] &0x02)? "True":"False";
 +
    decode.AC2H_status= (bytes[1] &0x01)? "True":"False"; 
 +
    decode.DI2_status= (bytes[2] &0x08)? "True":"False";
 +
    decode.DI2_flag= (bytes[2] &0x04)? "True":"False";
 +
    decode.DI1_status= (bytes[2] &0x02)? "True":"False";
 +
    decode.DI1_flag= (bytes[2] &0x01)? "True":"False"; 
 +
  }
 +
 
 +
  if(bytes.length==11)
 +
  {
 +
    return decode;
 +
  }
 +
}
 +
</pre>
 +
 +
==== Applications > [app] > Data ====
 +
 +
<pre>
 +
Fields:
 +
 +
{
 +
  "ACI1_mA": 0,
 +
  "ACI2_mA": 0,
 +
  "AVI1_V": 0,
 +
  "AVI2_V": 0,
 +
  "DI1_status": "H",
 +
  "DI2_status": "H",
 +
  "DO1_status": "H",
 +
  "DO2_status": "H",
 +
  "Hardware_mode": "LT22222",
 +
  "RO1_status": "OFF",
 +
  "RO2_status": "OFF",
 +
  "Work_mode": "2ACI+2AVI"
 +
}
 +
 +
Metadata (meines Gateways):
 +
 +
{
 +
  "time": "2021-03-04T13:53:19.117270901Z",
 +
  "frequency": 867.3,
 +
  "modulation": "LORA",
 +
  "data_rate": "SF7BW125",
 +
  "coding_rate": "4/5",
 +
  "gateways": [
 +
    {
 +
      "gtw_id": "eui-3133303718004a00",
 +
      "timestamp": 900120461,
 +
      "time": "2021-03-04T13:53:19.547715Z",
 +
      "channel": 4,
 +
      "rssi": -56,
 +
      "snr": 11.5
 +
    }
 +
  ],
 +
  "latitude": 51.572525,
 +
  "longitude": 6.7609153,
 +
  "altitude": 3,
 +
  "location_source": "registry"
 +
}
 +
</pre>
  
 
== thethingsnetwork.org ==
 
== thethingsnetwork.org ==
Line 28: Line 185:
  
 
== ttnmapper.org ==
 
== ttnmapper.org ==
 +
=== gateway ===
 
* https://ttnmapper.org/?lat=51.5573&lon=6.7442&zoom=12&layer=mapnik
 
* https://ttnmapper.org/?lat=51.5573&lon=6.7442&zoom=12&layer=mapnik
 
* https://ttnmapper.org/gateways/?gateway=eui-3133303718004a00&startdate=&enddate=&gateways=on&lines=on&points=on
 
* https://ttnmapper.org/gateways/?gateway=eui-3133303718004a00&startdate=&enddate=&gateways=on&lines=on&points=on
* ...
+
=== device ===
 +
* ''Applications > [app] > Integrations > TTN Mapper'' is needed to pass location towards ttnmapper.org
 +
** device will be 'private' if 'experiment name' is set!
 +
 
  
 
[[category:Projekte]]
 
[[category:Projekte]]

Latest revision as of 14:57, 27 February 2023

aim

set-up

devices

gateways

ttn

Applications > [device lt-22222-l] > Payload Formats > decoder

function Decoder(bytes, port) {
  var hardware= (bytes[10] & 0xC0)>>6;
  var mode0= bytes[10] & 0xff;
  var mode= bytes[10] & 0x3f;
  var decode = {};
  
  if(hardware=='0')
  {
    decode.Hardware_mode="LT33222";
    decode.DO3_status=(bytes[8] &0x04)? "L":"H";
    if(mode0=='1')
    {
    	decode.DI3_status= (bytes[8] &0x20)?"H":"L"; 
    }
  }
  else if(hardware=='1')
  {
    decode.Hardware_mode= "LT22222";
  }
  
  if(mode!=6)
  {
    decode.DO1_status= (bytes[8] &0x01)? "L":"H";
    decode.DO2_status= (bytes[8] &0x02)? "L":"H";
    decode.RO1_status= (bytes[8] &0x80)? "ON":"OFF";
    decode.RO2_status= (bytes[8] &0x40)? "ON":"OFF";
    if(mode!=1)
    {
      if(mode!=5)
      {
       decode.Count1_times= (bytes[0]<<24 | bytes[1]<<16 | bytes[2]<<8 | bytes[3]);
      }
      decode.First_status= (bytes[8] &0x20)? "Yes":"No";
    }
  }
  
  if(mode=='1')
  {
    decode.Work_mode= "2ACI+2AVI";
    decode.AVI1_V= parseFloat(((bytes[0]<<24>>16 | bytes[1])/1000).toFixed(3));
    decode.AVI2_V= parseFloat(((bytes[2]<<24>>16 | bytes[3])/1000).toFixed(3));
    decode.ACI1_mA= parseFloat(((bytes[4]<<24>>16 | bytes[5])/1000).toFixed(3));
    decode.ACI2_mA= parseFloat(((bytes[6]<<24>>16 | bytes[7])/1000).toFixed(3));
    decode.DI1_status= (bytes[8] &0x08)? "H":"L";
    decode.DI2_status= (bytes[8] &0x10)? "H":"L"
  }
  else if(mode=='2')
  {
    decode.Work_mode= "Count mode 1";
    decode.Count2_times= (bytes[4]<<24 | bytes[5]<<16 | bytes[6]<<8 | bytes[7]);
  }
  else if(mode=='3')
  {
    decode.Work_mode= "2ACI+1Count";
    decode.ACI1_mA= parseFloat(((bytes[4]<<24>>16 | bytes[5])/1000).toFixed(3));
    decode.ACI2_mA= parseFloat(((bytes[6]<<24>>16 | bytes[7])/1000).toFixed(3));
  }
  else if(mode=='4')
  {
    decode.Work_mode= "Count mode 2";
    decode.Acount_times= (bytes[4]<<24 | bytes[5]<<16 | bytes[6]<<8 | bytes[7]);
  }
  else if(mode=='5')
  {
    decode.Work_mode= " 1ACI+2AVI+1Count";
    decode.AVI1_V= parseFloat(((bytes[0]<<24>>16 | bytes[1])/1000).toFixed(3));
    decode.AVI2_V= parseFloat(((bytes[2]<<24>>16 | bytes[3])/1000).toFixed(3));
    decode.ACI1_mA= parseFloat(((bytes[4]<<24>>16 | bytes[5])/1000).toFixed(3));
    decode.Count1_times= bytes[6]<<8 | bytes[7];
  }
  else if(mode=='6')
  {
    decode.Work_mode= "Exit mode"; 
    decode.Mode_status= bytes[9] ? "True":"False";
    decode.AV1L_flag= (bytes[0] &0x80)? "True":"False";
    decode.AV1H_flag= (bytes[0] &0x40)? "True":"False";
    decode.AV2L_flag= (bytes[0] &0x20)? "True":"False";
    decode.AV2H_flag= (bytes[0] &0x10)? "True":"False";   
    decode.AC1L_flag= (bytes[0] &0x08)? "True":"False";
    decode.AC1H_flag= (bytes[0] &0x04)? "True":"False";
    decode.AC2L_flag= (bytes[0] &0x02)? "True":"False";
    decode.AC2H_flag= (bytes[0] &0x01)? "True":"False";   
    decode.AV1L_status= (bytes[1] &0x80)? "True":"False";
    decode.AV1H_status= (bytes[1] &0x40)? "True":"False";
    decode.AV2L_status= (bytes[1] &0x20)? "True":"False";
    decode.AV2H_status= (bytes[1] &0x10)? "True":"False";   
    decode.AC1L_status= (bytes[1] &0x08)? "True":"False";
    decode.AC1H_status= (bytes[1] &0x04)? "True":"False";
    decode.AC2L_status= (bytes[1] &0x02)? "True":"False";
    decode.AC2H_status= (bytes[1] &0x01)? "True":"False";   
    decode.DI2_status= (bytes[2] &0x08)? "True":"False";
    decode.DI2_flag= (bytes[2] &0x04)? "True":"False";
    decode.DI1_status= (bytes[2] &0x02)? "True":"False";
    decode.DI1_flag= (bytes[2] &0x01)? "True":"False";   
  }
  
  if(bytes.length==11)
  {
    return decode;
  }
}

Applications > [app] > Data

Fields:

{
  "ACI1_mA": 0,
  "ACI2_mA": 0,
  "AVI1_V": 0,
  "AVI2_V": 0,
  "DI1_status": "H",
  "DI2_status": "H",
  "DO1_status": "H",
  "DO2_status": "H",
  "Hardware_mode": "LT22222",
  "RO1_status": "OFF",
  "RO2_status": "OFF",
  "Work_mode": "2ACI+2AVI"
}

Metadata (meines Gateways):

{
  "time": "2021-03-04T13:53:19.117270901Z",
  "frequency": 867.3,
  "modulation": "LORA",
  "data_rate": "SF7BW125",
  "coding_rate": "4/5",
  "gateways": [
    {
      "gtw_id": "eui-3133303718004a00",
      "timestamp": 900120461,
      "time": "2021-03-04T13:53:19.547715Z",
      "channel": 4,
      "rssi": -56,
      "snr": 11.5
    }
  ],
  "latitude": 51.572525,
  "longitude": 6.7609153,
  "altitude": 3,
  "location_source": "registry"
}

thethingsnetwork.org

neighborhood gateways

neighborhood communities


ttnmapper.org

gateway

device

  • Applications > [app] > Integrations > TTN Mapper is needed to pass location towards ttnmapper.org
    • device will be 'private' if 'experiment name' is set!