LoRa TTN Node
1.0.0


The data is much more beautiful when you can view it. This project makes it easy to send data from nodes lorawan sensor connected to the Things network.
In this repository you find a Step by Step to record a Node (Arduino Uno) on the TTN platform and how to send to this sensor values: GPS, humidity, temperature and brightness using Lora.
To view data on a map and in the form of a chart, you can use this repository: https://github.com/daeynastas/lora-ttn-map

static const PROGMEM u1_t NWKSKEY[ 16 ] = { 0x82 , 0x60 }; // COLOCAR AQUI "Network Session Key" (ver screenshot)
static const u1_t PROGMEM APPSKEY[ 16 ] = { 0x59 , 0x76 }; // COLOCAR AQUI "App Session Key"
static const u4_t DEVADDR = 0x26011874 ; // COLOCAR AQUI "0xDevice Address" implicitly indicate the freq. that configured in the dragino, in this case "868300000"
# if defined(CFG_eu868)
// LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
LMIC_setupChannel ( 1 , 868300000 , DR_RANGE_MAP(DR_SF12, DR_SF7B), BAND_CENTI); // g-band
// LMIC_setupChannel(2, 868500000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(3, 867100000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(4, 867300000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(5, 867500000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(6, 867700000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(7, 867900000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_FSK, DR_FSK), BAND_MILLI); // g2-band.
$ git clone https://github.com/daeynasvistas/LoRa-TTN-Node
Used pounds
lib_deps =
# Depend on specific version
DHTlib
[email protected]+arduino-2
TinyGPS


Using Gateway Mac with ID: '' '' A840411111BC834FFF <- Add F up to 16bit '' '









function Bytes2Float32 ( bytes ) {
var sign = ( bytes & 0x80000000 ) ? - 1 : 1 ;
var exponent = ( ( bytes >> 23 ) & 0xFF ) - 127 ;
var significand = ( bytes & ~ ( - 1 << 23 ) ) ;
if ( exponent == 128 )
return sign * ( ( significand ) ? Number . NaN : Number . POSITIVE_INFINITY ) ;
if ( exponent == - 127 ) {
if ( significand == 0 ) return sign * 0.0 ;
exponent = - 126 ;
significand /= ( 1 << 22 ) ;
} else significand = ( significand | ( 1 << 23 ) ) / ( 1 << 23 ) ;
return sign * significand * Math . pow ( 2 , exponent ) ;
}
// Test using 0xFF1641 for -23.4 and 65%, or 0x00EA41 for +23.4 and 65%
function Decoder ( bytes , port ) {
var lat = bytes [ 3 ] << 24 | bytes [ 2 ] << 16 | bytes [ 1 ] << 8 | bytes [ 0 ] ;
var lon = bytes [ 7 ] << 24 | bytes [ 6 ] << 16 | bytes [ 5 ] << 8 | bytes [ 4 ] ;
var lux = bytes [ 8 ] << 8 | bytes [ 9 ] ;
var temp = bytes [ 10 ] << 24 >> 16 | bytes [ 11 ] ;
var hum = bytes [ 12 ] << 8 | bytes [ 13 ] ;
return {
latitude : Bytes2Float32 ( lat ) ,
longitude : Bytes2Float32 ( lon ) ,
Temperatura : ( temp / 100 ) ,
Humidade : ( hum / 100 ) ,
Luminosidade : ( lux ) ,
} ;
} 