sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
Uno_Dragino_LoRa_GPS_Shield_TTN.ino File Reference

Send GPS and Sensor Data as valid LoRaWAN packet to TTN. More...

#include <lmic.h>
#include <hal/hal.h>
#include <SoftwareSerial.h>
#include <TinyGPS.h>

Functions

SoftwareSerial ss (A2, A1)
 
void os_getArtEui (u1_t *buf)
 
void os_getDevEui (u1_t *buf)
 
void os_getDevKey (u1_t *buf)
 
void do_send (osjob_t *j)
 
void onEvent (ev_t ev)
 
void GPSRead ()
 
void GPSPrint ()
 
void setup ()
 
void loop ()
 
float readVcc ()
 
float readTemp (void)
 

Variables

const unsigned TX_INTERVAL = 20
 
unsigned int count = 1
 
TinyGPS gps
 
float flat
 
float flon
 
float falt
 
float payload [5]
 
const lmic_pinmap lmic_pins
 

Detailed Description

Send GPS and Sensor Data as valid LoRaWAN packet to TTN.

Author
drtrigon
Date
2018-07-25
Version
1.0
  • first version derived from
See Also
https://github.com/goodcheney/Arduino-Profile-Examples/blob/patch-4/libraries/Dragino/examples/LoRa/LoRaWAN/LoRa_GPS_Shield_TTN
https://github.com/dragino/Arduino-Profile-Examples/blob/master/libraries/Dragino/examples/LoRa/LoRaWAN/Arduino_LMIC/Arduino_LMIC.ino
https://github.com/dragino/Arduino-Profile-Examples/blob/master/libraries/Dragino/examples/GPS/tinygps_example/tinygps_example.ino
http://wiki.dragino.com/index.php?title=Connect_to_TTN#Create_LoRa_end_devices

This example sends a valid LoRaWAN packet with binary payload, using frequency and encryption settings matching those of the (early prototype version of) The Things Network.

Note: LoRaWAN per sub-band duty-cycle limitation is enforced (1% in g1, 0.1% in g2).

See Also
https://www.thethingsnetwork.org/docs/lorawan/duty-cycle.html

Change NWKSKEY, APPSKEY and DEVADDR to the keys given for your account and device. Currently it is defined for

See Also
https://console.thethingsnetwork.org/applications/vitudurum-drtrigon/devices/test_01

In order to retreive the data from TTN use the python script given Uno_Dragino_LoRa_GPS_Shield_TTN/request-data-ttn-restful.py

Data from TTN can be further processed in Node-RED. If a local install is not available consider using it online e.g. https://fred.sensetecnic.com/ and enable/install TTN library from menu. Currently I am not aware of any online grafana (or similar) tool.

Do not forget to define the radio type correctly in config.h. Currently set for Dragino LoRa GPS Shield.

Required Libraries:

Required Hardware:

Hardware Connection:

Thanks to: Thomas Telkamp - 2015 Matthijs Kooijman - 2015 Edwin Chen - modified 21 Mar 2017 suppo.nosp@m.rt@d.nosp@m.ragin.nosp@m.o.co.nosp@m.m Dragino Technology Co., Limited

Function Documentation

void do_send ( osjob_t *  j)
void GPSPrint ( )
void GPSRead ( )
void loop ( void  )

OneWirePJON device status update function.

Returns
(void)
void onEvent ( ev_t  ev)
void os_getArtEui ( u1_t *  buf)
void os_getDevEui ( u1_t *  buf)
void os_getDevKey ( u1_t *  buf)
float readTemp ( void  )

Internal Temperature Sensor for ATmega328 types.

Parameters
void
See Also
receiver_function()
https://playground.arduino.cc/Main/InternalTemperatureSensor
Returns
The chip temperature in [°C]
float readVcc ( )

Accessing the secret voltmeter on the Arduino 168 or 328.

See Also
receiver_function()
http://code.google.com/p/tinkerit/wiki/SecretVoltmeter
Returns
The supply voltage in [V]
void setup ( void  )

Arduino IDE: put your setup code here, to run once.

SoftwareSerial ss ( A2  ,
A1   
)

Variable Documentation

unsigned int count = 1
float falt
float flat
float flon
TinyGPS gps
const lmic_pinmap lmic_pins
Initial value:
= {
.nss = 10,
.rxtx = LMIC_UNUSED_PIN,
.rst = 9,
.dio = {2, 6, 7},
}
float payload[5]
const unsigned TX_INTERVAL = 20