Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ It is developed for Arduino Uno with Dragino Lora/GPS Shield and for ESP32 TTGO
- the software supports confirmed uplink and the Arduino will beep
- You can read the GPS over Hardware Serial or Software Serial, so it's easier for development if you see what is going on during real operation
- In case of Hardware Serial usage you can enable a Software Serial for debugging
- Adding keep alive timer option
## To Do
- Timed transmission, which also executes when the tracker is not moving. For example every hour, to see if the tracker is still alive.
- ~~Timed transmission, which also executes when the tracker is not moving. For example every hour, to see if the tracker is still alive.~~
- low power option
- ~~ESP32 support [State: in work, see branch develop. The SPI Config produces backtraces] Hardware: ESP32 Uno, branded as Wemos~~ ESP32 already implemented fot TTGO T-Beam
- Alternative WiFi Position for ESP32
Expand Down
22 changes: 21 additions & 1 deletion spgpstrack.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* TXspeedLOW - Maximum speed for low speed mode
* TXdistHIGH - Transmit Interval distance in high speed mode
* TXspeedLOW - Minimum speed for high speed mode
* keepAlive - number of seconds for keep alive sending, even if tracker does not move
* SF - Define The LoRaWAN Spreading Factor (DR_SF7 - DR_SF12) 7 and 8 recommended for Mapping
* CONFIRMED - enables Confirmed uplinks, ONLY Enable, if you conncect a Buzzer to Pin D5! Otherwise this Feature is useless
* SOFT_SERIAL - Uncomment to use Hardware Serial, Otherwise Software Serial is used. In that case connect the GPS Module to RXpin and TXpin
Expand Down Expand Up @@ -55,6 +56,10 @@
// min speed for high speed mode; in km/h
#define TXspeedHIGH 80

/* keep alive timer in seconds */
#define keepAlive // comment out if not wanted
#define keepAliveIntervall 60

/* Define Region */
#define CFG_eu868
/* Define Data Rate aka Sporeading Factor */
Expand Down Expand Up @@ -108,6 +113,7 @@ static const int RXPin = 4, TXPin = 3;
#ifdef ESP32
#include <Ticker.h>
Ticker tickerSampleGPS;
Ticker tickerKeepAlive;
#include <WiFi.h>
#endif

Expand Down Expand Up @@ -145,7 +151,6 @@ CayenneLPP lpp(20);
uint8_t txBuffer[9];
#endif


// ABP:

// LoRaWAN end-device address (DevAddr, MSB)
Expand Down Expand Up @@ -210,6 +215,9 @@ const lmic_pinmap lmic_pins = {

#endif

#ifdef keepAlive
unsigned long keepAliveTimer = millis() + keepAliveInervall * 1000;
#endif

void onEvent (ev_t ev) {
print(String(os_getTime()));
Expand Down Expand Up @@ -350,6 +358,7 @@ void setup() {
ESP_Serial.begin(GPSBaud, SERIAL_8N1, RXPin, TXPin);
ESP_Serial.setTimeout(2);
tickerSampleGPS.attach_ms(500, sampleGPS);
//ticker keepAlive ToDo
#else
#ifdef SOFT_SERIAL
// Setup for Software Serial Option
Expand Down Expand Up @@ -430,6 +439,9 @@ void setup() {

// Set data rate and transmit power for uplink (note: txpow seems to be ignored by the library)
LMIC_setDrTxpow(SF,14);

// set timer to actual millis + keepAlive value if activate

println("Setup OK");
}

Expand Down Expand Up @@ -470,6 +482,7 @@ void loop() {
//println( "Course: " + String(lastTxCourse));

// If Distance to last TX Point is bigger than the TXdistance Prepare and Trigger Data Transmission
// or if the keepAlive timer is reached
bool transmit = false;
#ifndef TXspeedModes
transmit = lastTxDist > TXdist; // No speed modes, Default TX distance
Expand All @@ -479,6 +492,13 @@ void loop() {
( (gps.speed.kmph() >= TXspeedHIGH ) && (lastTxDist > TXdistHIGH) ) || //High speed mode chek
(lastTxDist > TXdist); // Default TX distance
#endif
// check keepAlive timer
#ifdef keepAlive
if (keepAliveTimer < millis()){
keepAliveTimer = millis() + keepAliveIntervall * 1000; // set new timer value
transmit = true;
}
#endif
if( transmit ){
#ifdef DOUBLE_SEND
doDouble!=doDouble;
Expand Down