Lora Gateway and Nodes

From Simon's Help System
Jump to navigation Jump to search

Lora Gateway

Setup of the MicroTik wAP LR9 Access the Things Network Portal on https://au1.cloud.thethings.network/console/ ((link)

Add a gateway, but you must use the Gateway EUI which comes from WinBox

MikroTik1.png

Then add this Gateway EUI to the Gateways setting in TTN Portal
Also add the gateway Server Address to the au1.cloud.thethings.network

MikroTik3.png


MikroTik2.png

Nodes

Heltec

Link to LMIC setup for Heltec

Heltec data page on frequencies

Use platformio to upload and monitor Heltecs

On the TTN Console add new devices under the "applications" portal. Register a new device manually. Select "Show advanced activation...." to expose the ABP setiings


first page


Then generate a new DevEUI (not used) plus Device Address, AppSKey and NwkSKey which are used.


scroll down


Set the Network server address and application server address to my Australian portal


after scrolling some more


and save changes.

Once edited and added, then re-open the device under 'applications portal'. Scroll down and expand 'Network layer'

Heltec4.png


keep scrolling until you can expand the "Advanced MAC settings and select "Resets frame counter" to enabled

Heltec5.png

Add a payload formatter specific to this device


Heltec7.png

function Decoder(bytes, port) {
// Decode an uplink message from a buffer
// (array) of bytes to an object of fields.
var decoded = {};
// temperature
rawTemp = bytes[0] + bytes[1] * 256;
decoded.degreesC = sflt162f(rawTemp) * 100;
// humidity 
rawHumid = bytes[2] + bytes[3] * 256;
decoded.humidity = sflt162f(rawHumid) * 100;
return decoded;
}
 
function sflt162f(rawSflt16)
{
// rawSflt16 is the 2-byte number decoded from wherever;
// it's in range 0..0xFFFF
// bit 15 is the sign bit
// bits 14..11 are the exponent
// bits 10..0 are the the mantissa. Unlike IEEE format, 
// the msb is transmitted; this means that numbers
// might not be normalized, but makes coding for
// underflow easier.
// As with IEEE format, negative zero is possible, so
// we special-case that in hopes that JavaScript will
// also cooperate.
//
// The result is a number in the open interval (-1.0, 1.0);
//
// throw away high bits for repeatability.
rawSflt16 &= 0xFFFF;
 
// special case minus zero:
if (rawSflt16 == 0x8000)
    return -0.0;
 
// extract the sign.
var sSign = ((rawSflt16 & 0x8000) != 0) ? -1 : 1;
 
// extract the exponent
var exp1 = (rawSflt16 >> 11) & 0xF;
 
// extract the "mantissa" (the fractional part)
var mant1 = (rawSflt16 & 0x7FF) / 2048.0;
 
// convert back to a floating point number. We hope 
// that Math.pow(2, k) is handled efficiently by
// the JS interpreter! If this is time critical code,
// you can replace by a suitable shift and divide.
var f_unscaled = sSign * mant1 * Math.pow(2, exp1 - 15);
 
return f_unscaled;
}


Then in Visual Studio Code, open the platformio.ini file and enter the device address, NWKSKEY and APPSKEY as per the values created in the portal above


Heltec6.png