Skip to content

Commit

Permalink
Added WX functionality, fixed position profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Slayingripper committed Feb 11, 2022
1 parent d3f00e7 commit d032936
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 36 deletions.
147 changes: 115 additions & 32 deletions src/LoRa_APRS_Tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
#include "display.h"
#include <APRS-Decoder.h>
#include <Arduino.h>
#include <BMP180.h>
#include <TimeLib.h>
//#include <EEPROM.h>
#include <Wire.h>

// initialize the library with the numbers of the interface pins
char PRESSURESHOW[4]; // initializing a character of size 4 for showing the result
char TEMPARATURESHOW[4]; // initializing a character of size 4 for showing the temparature result
BMP085 bmp;
//#include <EEPROM.h>
Air530ZClass gps;
extern uint8_t isDispayOn; // Defined in LoRaWan_APP.cpp

Expand All @@ -16,16 +22,17 @@ void setup_gps();
void sleep_gps();
void userKey();

String create_lat_aprs(RawDegrees lat);
String create_long_aprs(RawDegrees lng);
String create_lat_aprs_dao(RawDegrees lat);
String create_long_aprs_dao(RawDegrees lng);
String create_dao_aprs(RawDegrees lat, RawDegrees lng);
String createDateString(time_t t);
String createTimeString(time_t t);
String getSmartBeaconState();
String padding(unsigned int number, unsigned int width);

String create_lat_aprs(RawDegrees lat);
String create_long_aprs(RawDegrees lng);
String create_lat_aprs_dao(RawDegrees lat);
String create_long_aprs_dao(RawDegrees lng);
String create_dao_aprs(RawDegrees lat, RawDegrees lng);
String createDateString(time_t t);
String createTimeString(time_t t);
String getSmartBeaconState();
String padding(unsigned int number, unsigned int width);
int TEMP, PRESS, HUMID, WIND_S, WIND_DIR, RAIN;
static bool STATIC_BEACON, WEATHER_DATA;
static bool BatteryIsConnected = false;
static String batteryVoltage = "";
static bool DSB_ACTIVE = SB_ACTIVE; // initial Smartbeacon State can be changed via menu
Expand All @@ -36,6 +43,8 @@ static String DBEACON_SYMBOL = BEACON_SYMBOL;
static String DBEACON_OVERLAY = BEACON_OVERLAY;
static String DBEACON_MESSAGE = BEACON_MESSAGE;
static String DCALLSIGN = CALLSIGN;
static String DBEACON_LATITUDE = BEACON_LATITUDE;
static String DBEACON_LONGITUDE = BEACON_LONGITUDE;

static bool send_update = true;
static bool is_txing = false;
Expand Down Expand Up @@ -87,21 +96,19 @@ uint8_t getBattStatus();
void switchScrenOffMode();
void switchScrenOnMode();
void activateProfile(int profileNr);

// int address = 0;
// byte value;

// cppcheck-suppress unusedFunction
// cppcheck-suppress unusedFunction
void setup() {
boardInitMcu();
Serial.begin(115200);

delay(500);
Serial.println("CubeCell LoRa APRS Tracker, DJ1AN");
setup_display();
VextON(); // activate RGB Pixel
show_display("DJ1AN", "CubeCell", "LoRa APRS Tracker", 500);

bmp.begin();
pinMode(Vext, OUTPUT);
setup_gps();
setup_lora();

Expand Down Expand Up @@ -131,7 +138,28 @@ void setup() {
batteryVoltage = String(getBattVoltage());
// EEPROM.begin(512);
}

void telemetry() {
pinMode(Vext, OUTPUT);
digitalWrite(Vext, LOW);
Serial.begin(115200);
if (!bmp.begin()) {
Serial.println("Could not find a valid BMP085 sensor, check wiring!");
return;
}
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" *C");
TEMP = bmp.readTemperature();
// convert temp to farhenheit
// APRS expects temp in Farenheit
TEMP = (TEMP * 9 / 5) + 32;
Serial.print("Pressure = ");
Serial.print(bmp.readPressure());
Serial.println(" Pa");
PRESS = bmp.readPressure();
// HUMID = bmp.readHumidity();
delay(500);
}
// cppcheck-suppress unusedFunction
void loop() {
// userButton.tick();
Expand Down Expand Up @@ -280,25 +308,61 @@ void loop() {
} else {
speed_zero_sent = 0;
}

telemetry();
String TEMPERATURE = String(TEMP);
String PRESSURE = String(PRESS);
// REMOVE LAST CHARACTER FROM PRESSURE
PRESSURE.remove(PRESSURE.length() - 1); // PRESSURE ON APRS IS ONLY 5 DIGITS

// Uncomment to enable APRS telemetry for sensors with more data.

/// String HUMIDITY = String(HUMID);
/// String WIND_SPEED = String(WIND_S);
/// String WIND_DIRECTION = String(WIND_DIR);
/// String RAINX = String(RAIN);

// Using ... notifies APRS that the fields are NULL thus not showing up
// in the telemetry.
String HUMIDITY = "...";
String WIND_SPEED = "...";
String WIND_DIRECTION = "...";
String RAINX = "...";
String aprsmsg;
aprsmsg = "!" + lat + DBEACON_OVERLAY + lng + DBEACON_SYMBOL + course_and_speed + alt;
// message_text every 10's packet (i.e. if we have beacon rate 1min at high
// speed -> every 10min). May be enforced above (at expirey of smart beacon
// rate (i.e. every 30min), or every third packet on static rate (i.e.
// static rate 10 -> every third packet)
if (!(rate_limit_message_text++ % 10)) {
aprsmsg += DBEACON_MESSAGE;
if (WEATHER_DATA == true) {

Serial.print("Weather data enabled");
aprsmsg = "!" + lat + DBEACON_OVERLAY + lng + DBEACON_SYMBOL + WIND_DIRECTION + "/" + WIND_SPEED + "g" + RAINX + "t" + TEMPERATURE + "h" + HUMIDITY + "b" + PRESSURE;

if (BatteryIsConnected) {
aprsmsg += " - U: " + batteryVoltage + "V";
aprsmsg += DBEACON_MESSAGE;
// t = temprature
// h = humidity
// b = pressure
} else if (STATIC_BEACON == true) {
aprsmsg = "!" + DBEACON_LATITUDE + DBEACON_OVERLAY + DBEACON_LONGITUDE + DBEACON_SYMBOL + DBEACON_MESSAGE;
} else {
aprsmsg = "!" + lat + DBEACON_OVERLAY + lng + DBEACON_SYMBOL + course_and_speed + alt;
// message_text every 10's packet (i.e. if we have beacon rate 1min at high
// speed -> every 10min). May be enforced above (at expirey of smart beacon
// rate (i.e. every 30min), or every third packet on static rate (i.e.
// static rate 10 -> every third packet)
if (!(rate_limit_message_text++ % 10)) {
aprsmsg += DBEACON_MESSAGE;
// convert char to string

if (BatteryIsConnected) {
aprsmsg += " - U: " + batteryVoltage + "V";
}
}
}

if (ENHANCE_PRECISION) {
aprsmsg += " " + dao;
if (ENHANCE_PRECISION) {
aprsmsg += " " + dao;
// aprsmsg += " ";
// aprsmsg += TEMPERATURE;
// aprsmsg += "C ";
// aprsmsg += PRESSURE;
// aprsmsg += "Pa";
}
}

msg.getAPRSBody()->setData(aprsmsg);
String data = msg.encode();

Expand Down Expand Up @@ -713,7 +777,7 @@ void executeMenu(void) {

case PROFILE:
DPROFILE_NR += 1;
if (DPROFILE_NR > 2) {
if (DPROFILE_NR > 4) {
DPROFILE_NR = 0;
}
activateProfile(DPROFILE_NR);
Expand Down Expand Up @@ -900,5 +964,24 @@ void activateProfile(int profileNr) {
DBEACON_SYMBOL = P2_BEACON_SYMBOL;
DCALLSIGN = P2_CALLSIGN;
break;
case 3:
DSB_ACTIVE = P3_SB_ACTIVE;
DBEACON_TIMEOUT = P3_BEACON_TIMEOUT;
DBEACON_MESSAGE = P3_BEACON_MESSAGE;
DBEACON_OVERLAY = P3_BEACON_OVERLAY;
DBEACON_SYMBOL = P3_BEACON_SYMBOL;
DCALLSIGN = P3_CALLSIGN;
WEATHER_DATA = true;
break;
case 4:
DSB_ACTIVE = P4_SB_ACTIVE;
DBEACON_TIMEOUT = P4_BEACON_TIMEOUT;
DBEACON_MESSAGE = P4_BEACON_MESSAGE;
DBEACON_OVERLAY = P4_BEACON_OVERLAY;
DBEACON_SYMBOL = P4_BEACON_SYMBOL;
DBEACON_LATITUDE = BEACON_LATITUDE;
DBEACON_LONGITUDE = BEACON_LONGITUDE;
DCALLSIGN = P4_CALLSIGN;
STATIC_BEACON = true;
}
}
27 changes: 23 additions & 4 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,49 @@
// Symbol Lookup Table:
// https://blog.thelifeofkenneth.com/2017/01/aprs-symbol-look-up-table.html

#define DEFAULT_PROFILE 0 // Profile to use after Reboot
#define DEFAULT_PROFILE 3 // Profile to use after Reboot

// Profile 0 - Car Symbol
#define BEACON_SYMBOL ">"
#define BEACON_OVERLAY "/"
#define BEACON_MESSAGE "Cubecell LoRa Tracker"
#define SB_ACTIVE true // smart Beacon
#define BEACON_TIMEOUT 60 // fixed Beacon interval in s if Smartbeacon inactive
#define CALLSIGN "N0CALL-7" // your callsign
#define CALLSIGN "-7" // your callsign

// Profile 1 - Runner Symbol
#define P1_BEACON_SYMBOL "["
#define P1_BEACON_OVERLAY "/"
#define P1_BEACON_MESSAGE "Running Cubecell LoRa"
#define P1_SB_ACTIVE true // smart Beacon
#define P1_BEACON_TIMEOUT 60 // fixed Beacon interval in s if Smartbeacon inactive
#define P1_CALLSIGN "N0CALL-8" // your callsign
#define P1_CALLSIGN "-8" // your callsign

// Profile 2 - Balloon
#define P2_BEACON_SYMBOL "O"
#define P2_BEACON_OVERLAY "/"
#define P2_BEACON_MESSAGE "Cubecell LoRa powered Balloon"
#define P2_SB_ACTIVE false // smart Beacon
#define P2_BEACON_TIMEOUT 30 // fixed Beacon interval in s if Smartbeacon inactive
#define P2_CALLSIGN "N0CALL-12" // your callsign
#define P2_CALLSIGN "-12" // your callsign

// Profile 3 - WX Station
#define P3_BEACON_SYMBOL "_"
#define P3_BEACON_OVERLAY "/"
#define P3_BEACON_MESSAGE "Cubecell LoRa WX Station"
#define P3_SB_ACTIVE true // smart Beacon
#define P3_BEACON_TIMEOUT 60 // fixed Beacon interval in s if Smartbeacon inactive
#define P3_CALLSIGN "-13" // your callsign

// Profile 4 - Fixed Station Location (House Symbol)
#define P4_BEACON_SYMBOL "-"
#define P4_BEACON_OVERLAY "/"
#define P4_BEACON_MESSAGE "Cubecell LoRa APRS"
#define BEACON_LATITUDE "" // your latitude N OR S UP TO 2 DECIMAL PLACES
#define BEACON_LONGITUDE "" // your longitude W OR E UP TO 2 DECIMAL PLACES
#define P4_SB_ACTIVE true // smart Beacon
#define P4_BEACON_TIMEOUT 60 // fixed Beacon interval in s if Smartbeacon inactive
#define P4_CALLSIGN "-3" // your callsign


// Global Settings for All Profiles
Expand Down Expand Up @@ -82,3 +100,4 @@
#define BEACON_BUTTON_TX true // Push Button >2s to Tx Position
#define ENHANCE_PRECISION true // APRS DAO Extension. Adds two Digits of Precision to Lat and Lon


0 comments on commit d032936

Please sign in to comment.