From 818d7a422cc7ee0fe069e410b8384762ee16682a Mon Sep 17 00:00:00 2001 From: richonguzman Date: Sat, 28 Jan 2023 13:40:50 -0300 Subject: [PATCH 1/3] mods to repair ESP32 hangs --- README.md | 29 +++++++++++++++++++---------- src/Lora_1W_APRS_Tracker.cpp | 2 +- src/beacon_config.h | 20 ++++++++++++++++++-- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 040002e..d60a3e8 100644 --- a/README.md +++ b/README.md @@ -7,29 +7,38 @@ This LORA APRS Tracker will work with very cheep hardware (amazon, ebay or aliex This project uses Enconded APRS GPS packet to extends range by saving bytes (increased battery life, higher chances of good packet reception (increased range), lower probability of packet collisions (more channel capacity) and 1 Watt LoRa Module (over the usual 0.1 Watt in commercial boards like the LILYGO T-Beam V.1). +______________________________________________________________________ + +Achievements: + +- changing CALLSINGs with the "long" push of a button. +- custom smartbeacon values for each CALLSIGN +- force Tx with the "short" push of a button. +- send enconded GPS data packet for shorter and realiable comunication. +- To add (shortly) working on it + +- turn_slope for course angle smartbeacon +- oled screen (allready bought ... and waiting.. ) +- SendAltitude: encoded instead of just "Course+Speed" without adding lenght to the APRS packet. +- SendComment: for a GPS position or distance to certain GPS point +- Send Status: for a GPS position or distance to certain GPS point +- Send Message to anothe APRS capable Radio/Handy/tracker/iGate or even Twitter ;) +- Battery Monitoring (voltage, consumption, low_battery warning, charging?) - - - +______________________________________________________________________ This Repository is based on lots of other Lora APRS Tracker ideas like: - https://github.com/lora-aprs/LoRa_APRS_Tracker (the start with LILYGO T-BEAM v.1) - https://github.com/aprs434/lora.tracker (the great encoding position modification) - https://github.com/Mane76/lora.tracker (great ideas about changing callsign and other mods) - https://github.com/sh123/esp32_loraprs (inspiration for accesing the Lora Module with Radiolib library) - - - +______________________________________________________________________ things to do: - add wiki -- add status update (on the works) -- add message to another APRS capable Radio (on the works) - add translation to Spanish (and German?) -- add OLED Screen (allready Bought) - add schematic for the wiring - add info of 5V DC stepup and charging battery -- add battery monitoring + charging - add photos of prototipe - add PCB (with eagle and gerber) diff --git a/src/Lora_1W_APRS_Tracker.cpp b/src/Lora_1W_APRS_Tracker.cpp index 6104279..4e43b19 100644 --- a/src/Lora_1W_APRS_Tracker.cpp +++ b/src/Lora_1W_APRS_Tracker.cpp @@ -19,7 +19,7 @@ https://github.com/sh123/esp32_loraprs #include "lora_config.h" #include "beacon_config.h" -#define VERSION "2023.01.24" // BETA!!! +#define VERSION "2023.01.28" // BETA!!! SX1268 radio = new Module(NSS, DIO1, NRST, BUSY); HardwareSerial neo6m_gps(1); diff --git a/src/beacon_config.h b/src/beacon_config.h index 8cd3e92..d155687 100644 --- a/src/beacon_config.h +++ b/src/beacon_config.h @@ -6,10 +6,26 @@ #define FastRate 60 // Seg #define FastSpeed 20 // Km/h (20 Runner y Bike, 70 Car) #define TurnDegrees 20 // Degrees before Forced Beacon Tx (20 Car , 15 Bike/Runner) -#define MinimumDistanceTx 30 // Mts (20 Runner, 100 Car/Bike) +#define MinimumDistanceTx 3 // Mts (20 Runner, 100 Car/Bike) #define MinimumTimeDeltaBeacon 5 // Seg between Tx #define SendAltitude true // "true" adds Altitude to the APRS packet/message, "false" add Course+Speed #define SendComment false // "true" adds comment to the APRS packet/message -#endif \ No newline at end of file +#endif + +/* +"callsign": "NOCALL-10", + "timeout": 1, + "symbol": "b", + "overlay": "/", + "smart_beacon": { + "active": true, + "turn_min": 15, + "slow_rate": 120, + "slow_speed": 5, + "fast_rate": 60, + "fast_speed": 20, + "min_tx_dist": 100, + "min_bcn": 5 +*/ \ No newline at end of file From 72414cd40d8bbed76cdfbbd642464f085cc34589 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Sat, 28 Jan 2023 19:54:42 -0300 Subject: [PATCH 2/3] change beacon 2.0 --- README.md | 5 +- src/Lora_1W_APRS_Tracker.cpp | 86 +++++++++++++++++++++++++++++------ src/beacon_config.h | 74 ++++++++++++++++++++---------- src/{pins.h => pins_config.h} | 4 +- src/user_config.h | 9 ---- 5 files changed, 127 insertions(+), 51 deletions(-) rename src/{pins.h => pins_config.h} (94%) delete mode 100644 src/user_config.h diff --git a/README.md b/README.md index d60a3e8..0867926 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,10 @@ Achievements: - custom smartbeacon values for each CALLSIGN - force Tx with the "short" push of a button. - send enconded GPS data packet for shorter and realiable comunication. -- To add (shortly) working on it +- Select to send "Course + Speed" or "Altitude + Speed" in encoded APRS data packet + + +To add (shortly) working on it - turn_slope for course angle smartbeacon - oled screen (allready bought ... and waiting.. ) diff --git a/src/Lora_1W_APRS_Tracker.cpp b/src/Lora_1W_APRS_Tracker.cpp index 4e43b19..87853a0 100644 --- a/src/Lora_1W_APRS_Tracker.cpp +++ b/src/Lora_1W_APRS_Tracker.cpp @@ -14,8 +14,7 @@ https://github.com/sh123/esp32_loraprs #include #include #include -#include "user_config.h" -#include "pins.h" +#include "pins_config.h" #include "lora_config.h" #include "beacon_config.h" @@ -26,8 +25,23 @@ HardwareSerial neo6m_gps(1); TinyGPSPlus gps; OneButton UserButton1 = OneButton(BUTTON1_PIN, true, true); + +String CurrentUser[10]; static bool send_update = true; +String CALLSIGN_CONFIG_1[10] = {User1_Callsign,User1_Symbol,String(User1_SlowRate),String(User1_SlowSpeed), + String(User1_FastRate),String(User1_FastSpeed),String(User1_MinDistTx), + String(User1_MinDeltaBcn),String(User1_TurnMin),String(User1_TurnSlope)}; + +String CALLSIGN_CONFIG_2[10] = {User2_Callsign,User2_Symbol,String(User2_SlowRate),String(User2_SlowSpeed), + String(User2_FastRate),String(User2_FastSpeed),String(User2_MinDistTx), + String(User2_MinDeltaBcn),String(User2_TurnMin),String(User2_TurnSlope)}; + +String CALLSIGN_CONFIG_3[10] = {User3_Callsign,User3_Symbol,String(User3_SlowRate),String(User3_SlowSpeed), + String(User3_FastRate),String(User3_FastSpeed),String(User3_MinDistTx), + String(User3_MinDeltaBcn),String(User3_TurnMin),String(User3_TurnSlope)}; + + void setup_lora_module() { int state = radio.begin(LoraFreqTx, LoraBandWidth, LoraSpreadingFactor, LoraCodingRate, LoraSyncWord, LoraOutro, LoraPreampbleLenght); radio.setOutputPower(Lora_Power); @@ -44,24 +58,58 @@ void setup_gps_module() { neo6m_gps.begin(9600, SERIAL_8N1, GPS_TXD, GPS_RXD); } +void setup_first_user() { + for (int i = 0; i<10; i++ ) { + CurrentUser[i] = CALLSIGN_CONFIG_1[i]; + } + Serial.print("Current User --> "); + Serial.println(CurrentUser[0]); +} + static void ForcedBeaconTx() { Serial.println("Forced Beacon Tx"); send_update = true; } +static void HandleNextBeacon() { + if (CurrentUser[0] == CALLSIGN_CONFIG_1[0]){ + Serial.print("Changing CALLSIGN to --> "); + Serial.println(CALLSIGN_CONFIG_2[0]); + for (int i = 0; i<10; i++ ) { + CurrentUser[i] = CALLSIGN_CONFIG_2[i]; + } + } else if (CurrentUser[0] == CALLSIGN_CONFIG_2[0]){ + Serial.print("Changing CALLSIGN to --> "); + Serial.println(CALLSIGN_CONFIG_3[0]); + for (int i = 0; i<10; i++ ) { + CurrentUser[i] = CALLSIGN_CONFIG_3[i]; + } + } else if (CurrentUser[0] == CALLSIGN_CONFIG_3[0]){ + Serial.print("Changing CALLSIGN to --> "); + Serial.println(CALLSIGN_CONFIG_1[0]); + for (int i = 0; i<10; i++ ) { + CurrentUser[i] = CALLSIGN_CONFIG_1[i]; + } + } +} + void setup() { Serial.begin(115200); - Serial.println(F("LoRa tracker " __DATE__ " " __TIME__ " / Callsign ------> " SRC_CALLSIGN)); pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, LOW); - setup_lora_module(); - setup_gps_module(); - UserButton1.attachClick(ForcedBeaconTx); WiFi.mode(WIFI_OFF); btStop(); - Serial.print("Version = "); + UserButton1.attachClick(ForcedBeaconTx); + UserButton1.attachLongPressStart(HandleNextBeacon); + Serial.println(""); + Serial.println("****** LoRa APRS Tracker ******"); + Serial.println("https://github.com/richonguzman/LoRa_1W_APRS_Tracker"); + Serial.print("Version -------> "); Serial.println(VERSION); - Serial.println("Transmission Start ---->"); + setup_first_user(); + setup_lora_module(); + setup_gps_module(); + Serial.println("---Transmission Start ---"); } uint8_t tx_buffer[256]; @@ -97,9 +145,14 @@ void loop() { //static int speed_zero_sent = 0; if (!send_update && gps_loc_update) { - uint32_t lastTx = millis() - lastTxTime; - currentHeading = gps.course.deg(); - lastTxDistance = TinyGPSPlus::distanceBetween(gps.location.lat(), gps.location.lng(), lastTxLatitude, lastTxLongitude); + uint32_t lastTx = millis() - lastTxTime; + int MinimumDistanceTx = CurrentUser[6].toInt(); + int MinimumTimeDeltaBeacon = CurrentUser[7].toInt(); + int TurnDegrees = CurrentUser[8].toInt(); + int TurnSlope = CurrentUser[9].toInt(); + currentHeading = gps.course.deg(); + lastTxDistance = TinyGPSPlus::distanceBetween(gps.location.lat(), gps.location.lng(), lastTxLatitude, lastTxLongitude); + if (lastTx >= txInterval) { if (lastTxDistance > MinimumDistanceTx) { send_update = true; @@ -137,7 +190,7 @@ void loop() { if(Tlon < 0) { Tlon= -Tlon; } String AprsPacketMsg = "!"; - AprsPacketMsg += "/"; + AprsPacketMsg += AprsOverlay; char helper_base91[] = {"0000\0"}; int i; ax25_base91enc(helper_base91, 4, aprs_lat); @@ -149,7 +202,7 @@ void loop() { AprsPacketMsg += helper_base91[i]; } - AprsPacketMsg += SYMBOL; + AprsPacketMsg += CurrentUser[1]; // Symbol if (SendAltitude) { // Send Altitude or... (APRS calculates Speed also) int Alt1, Alt2; @@ -186,7 +239,7 @@ void loop() { memset(tx_buffer, 0x00, sizeof tx_buffer); uint16_t size = 0; - size = snprintf(reinterpret_cast(tx_buffer), sizeof tx_buffer, "\x3c\xff\x01%s>%s:%s", SRC_CALLSIGN, DST_CALLSIGN, AprsPacketMsg.c_str()); + size = snprintf(reinterpret_cast(tx_buffer), sizeof tx_buffer, "\x3c\xff\x01%s>%s:%s", CurrentUser[0], AprsPath, AprsPacketMsg.c_str()); Serial.print(millis()); // Only for Serial Monitor Serial.print(F(" transmitting: ")); @@ -206,6 +259,11 @@ void loop() { } if (gps_time_update) { // updating txInterval between Slow and FastRate or in between + int SlowRate = CurrentUser[2].toInt(); + int SlowSpeed = CurrentUser[3].toInt(); + int FastRate = CurrentUser[4].toInt(); + int FastSpeed = CurrentUser[5].toInt(); + int curr_speed = (int)gps.speed.kmph(); if (curr_speed < SlowSpeed) { txInterval = SlowRate * 1000; diff --git a/src/beacon_config.h b/src/beacon_config.h index d155687..dbbccf7 100644 --- a/src/beacon_config.h +++ b/src/beacon_config.h @@ -1,31 +1,55 @@ #ifndef BEACON_CONFIG_H_ #define BEACON_CONFIG_H_ -#define SlowRate 120 // Seg -#define SlowSpeed 10 // Km/h (3 Runner , 5 Bike, 10 Car) -#define FastRate 60 // Seg -#define FastSpeed 20 // Km/h (20 Runner y Bike, 70 Car) -#define TurnDegrees 20 // Degrees before Forced Beacon Tx (20 Car , 15 Bike/Runner) -#define MinimumDistanceTx 3 // Mts (20 Runner, 100 Car/Bike) -#define MinimumTimeDeltaBeacon 5 // Seg between Tx +//#define SlowRate 120 // Seg +//#define SlowSpeed 10 // Km/h (3 Runner , 5 Bike, 10 Car) +//#define FastRate 60 // Seg +//#define FastSpeed 20 // Km/h (20 Runner y Bike, 70 Car) +//#define TurnDegrees 20 // Degrees before Forced Beacon Tx (20 Car , 15 Bike/Runner) +//#define MinimumDistanceTx 3 // Mts (20 Runner, 100 Car/Bike) +//#define MinimumTimeDeltaBeacon 5 // Seg between Tx -#define SendAltitude true // "true" adds Altitude to the APRS packet/message, "false" add Course+Speed -#define SendComment false // "true" adds comment to the APRS packet/message +#define SendAltitude true // "true" adds Altitude to the APRS packet/message, "false" add Course+Speed +#define SendComment false // "true" adds comment to the APRS packet/message -#endif +#define APRS_COMMENT "Lora Tracker 1W" // if you want to send any comment change the APRS_COMMENT + // and also beacon_config.h > SendComment = true -/* -"callsign": "NOCALL-10", - "timeout": 1, - "symbol": "b", - "overlay": "/", - "smart_beacon": { - "active": true, - "turn_min": 15, - "slow_rate": 120, - "slow_speed": 5, - "fast_rate": 60, - "fast_speed": 20, - "min_tx_dist": 100, - "min_bcn": 5 -*/ \ No newline at end of file +#define AprsPath "AP" // APRS Destination (could be also "WIDE1-1") +#define AprsOverlay "/" + +#define User1_Callsign "CD2RXU-7" +#define User1_Symbol "[" // Runner +#define User1_SlowRate 120 +#define User1_SlowSpeed 3 +#define User1_FastRate 60 +#define User1_FastSpeed 20 +#define User1_MinDistTx 50 +#define User1_MinDeltaBcn 20 +#define User1_TurnMin 8 +#define User1_TurnSlope 60 + +#define User2_Callsign "CD2RXU-8" +#define User2_Symbol "b" // Bike +#define User2_SlowRate 180 +#define User2_SlowSpeed 5 +#define User2_FastRate 60 +#define User2_FastSpeed 40 +#define User2_MinDistTx 70 +#define User2_MinDeltaBcn 12 +#define User2_TurnMin 12 +#define User2_TurnSlope 80 + +#define User3_Callsign "CD2RXU-9" +#define User3_Symbol ">" // Car +#define User3_SlowRate 120 +#define User3_SlowSpeed 10 +#define User3_FastRate 60 +#define User3_FastSpeed 70 +#define User3_MinDistTx 100 +#define User3_MinDeltaBcn 10 +#define User3_TurnMin 15 +#define User3_TurnSlope 80 + + +#endif \ No newline at end of file diff --git a/src/pins.h b/src/pins_config.h similarity index 94% rename from src/pins.h rename to src/pins_config.h index 0099ca9..331129e 100644 --- a/src/pins.h +++ b/src/pins_config.h @@ -1,5 +1,5 @@ -#ifndef PINS_H_ -#define PINS_H_ +#ifndef PINS_CONFIG_H_ +#define PINS_CONFIG_H_ #define GPS_TXD 16 // Conection Pinout for GPS #define GPS_RXD 17 diff --git a/src/user_config.h b/src/user_config.h deleted file mode 100644 index 59b95c3..0000000 --- a/src/user_config.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef USER_CONFIG_H_ -#define USER_CONFIG_H_ - -#define SRC_CALLSIGN "CD2RXU-7" // Change "CD2RXU-7" to your CALLSIGN-SSID you would use in APRS -#define DST_CALLSIGN "AP" // APRS Destination (could be also "WIDE1-1") -#define SYMBOL "[" // APRS Symbol: "[" Runner, "b" Bike, ">" Auto/Car -#define APRS_COMMENT "Lora Tracker 1W" // if you want to send any comment change the APRS_COMMENT - // and also beacon_config.h > SendComment = true -#endif \ No newline at end of file From 6e869b89ee0aad020a04f207027967d3342d240a Mon Sep 17 00:00:00 2001 From: richonguzman Date: Sat, 28 Jan 2023 20:21:20 -0300 Subject: [PATCH 3/3] nuevamejora1 --- src/Lora_1W_APRS_Tracker.cpp | 7 ++++++- src/beacon_config.h | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Lora_1W_APRS_Tracker.cpp b/src/Lora_1W_APRS_Tracker.cpp index 87853a0..d281293 100644 --- a/src/Lora_1W_APRS_Tracker.cpp +++ b/src/Lora_1W_APRS_Tracker.cpp @@ -144,6 +144,8 @@ void loop() { static uint32_t txInterval = 60000L; //static int speed_zero_sent = 0; + + String mensaje_test = "0"; if (!send_update && gps_loc_update) { uint32_t lastTx = millis() - lastTxTime; int MinimumDistanceTx = CurrentUser[6].toInt(); @@ -156,6 +158,7 @@ void loop() { if (lastTx >= txInterval) { if (lastTxDistance > MinimumDistanceTx) { send_update = true; + mensaje_test = "D:" + String(lastTxDistance) + " I:" + String(txInterval); } } if (!send_update) { @@ -163,6 +166,7 @@ void loop() { if (lastTx > MinimumTimeDeltaBeacon * 1000) { if (headingDelta > TurnDegrees && lastTxDistance > MinimumDistanceTx) { send_update = true; + mensaje_test = "C:" + String(headingDelta) + " D:" + String(lastTxDistance) + " I:" + String(txInterval); } } } @@ -228,7 +232,8 @@ void loop() { } if (SendComment) { - AprsPacketMsg += APRS_COMMENT; + //AprsPacketMsg += APRS_COMMENT; + AprsPacketMsg += mensaje_test; } Serial.print(F("GPS coordinates: ")); // Only for Serial Monitor diff --git a/src/beacon_config.h b/src/beacon_config.h index dbbccf7..88d3399 100644 --- a/src/beacon_config.h +++ b/src/beacon_config.h @@ -10,7 +10,7 @@ //#define MinimumTimeDeltaBeacon 5 // Seg between Tx #define SendAltitude true // "true" adds Altitude to the APRS packet/message, "false" add Course+Speed -#define SendComment false // "true" adds comment to the APRS packet/message +#define SendComment true // "true" adds comment to the APRS packet/message #define APRS_COMMENT "Lora Tracker 1W" // if you want to send any comment change the APRS_COMMENT // and also beacon_config.h > SendComment = true @@ -24,7 +24,7 @@ #define User1_SlowSpeed 3 #define User1_FastRate 60 #define User1_FastSpeed 20 -#define User1_MinDistTx 50 +#define User1_MinDistTx 5 // debe ser 50 pero esta 5 por pruebas #define User1_MinDeltaBcn 20 #define User1_TurnMin 8 #define User1_TurnSlope 60