diff --git a/INSTALL.md b/INSTALL.md
new file mode 100644
index 0000000..3861e95
--- /dev/null
+++ b/INSTALL.md
@@ -0,0 +1,35 @@
+
Installation Guide using PlatformIO
+
+1. Clone all files of the respository to your local working directory
+2. Install the missing libraries
+There are two possibilities - either using the Library Manager of PlatformIO or the command line tool:
+1. Built-In Liabrary Manager
+Press the PlatformIO HOME Button to enter the Home Screen and there the Libraries Button to add missing libraries:
+
+Search and install the following libaries:
+
+- RadioHead
+- TinyGPSPlus
+- DHT sensor library for ESPx
+- Adafruit SSD1306
+- Adafruit GFX Library
+- Adafruit Unified Sensor
+- AXP202X_Library
+- OneWire
+- DallasTemperature
+
+
+2. Command Line Tool
+use the following commands
+platformio lib install "RadioHead"
+platformio lib install "TinyGPSPlus"
+platformio lib install "DHT sensor library for ESPx"
+platformio lib install "Adafruit SSD1306"
+platformio lib install "Adafruit GFX Library"
+platformio lib install "AXP202X_Library"
+platformio lib install "Adafruit Unified Sensor"
+platformio lib install "OneWire"
+platformio lib install "DallasTemperature"
+
+Check that the platformio.ini is available as it holds the board type for PlatformIO.
+After pressing the check mark the code will be compiled, after pressing the arrow it will be compiled and uploaded to a connected TTGO.
diff --git a/README.md b/README.md
index 0334d99..b78c547 100644
--- a/README.md
+++ b/README.md
@@ -32,9 +32,13 @@ The symbol can now be changed without attached display - during normal operation
2x TX LED blinks represent "yes" to leave the setup - press here the key to leave the setup - please do so if you don't have a display attached.
1x TX LED blinks represent "no" to continue with the setup - press here the key to continue the setup - please do so if you have a display attached.
+Temperature Sensor:
for DHT22 I used the library from https://github.com/beegee-tokyo/DHTesp, as the standard library gives to many wrong readings
+Now the DS18B20 is supported as well - uncomment line 31: // #define DS18B20 // use this if you use DS18B20, default ist DHT22
new features:
+- DS18B20 support (setable in config.h)
+- GPS switched off in WX_FIXED mode (only available with boards with HW-Version >=V1.0)
- immediate TX with short key press
- course changes of >30° will cause a TX beacon
- code optimized and cleaned
diff --git a/img/img1.jpg b/img/img1.jpg
new file mode 100644
index 0000000..b76c1fc
Binary files /dev/null and b/img/img1.jpg differ
diff --git a/src/BG_RF95.cpp b/lib/BG_RF95/BG_RF95.cpp
similarity index 100%
rename from src/BG_RF95.cpp
rename to lib/BG_RF95/BG_RF95.cpp
diff --git a/src/BG_RF95.h b/lib/BG_RF95/BG_RF95.h
similarity index 100%
rename from src/BG_RF95.h
rename to lib/BG_RF95/BG_RF95.h
diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino
index d3c15b8..14693b4 100644
--- a/src/TTGO_T-Beam_LoRa_APRS.ino
+++ b/src/TTGO_T-Beam_LoRa_APRS.ino
@@ -41,7 +41,12 @@
#include
#include
-#include // library from https://github.com/beegee-tokyo/DHTesp
+#ifdef DS18B20
+ #include // libraries for DS18B20
+ #include
+#else
+ #include // library from https://github.com/beegee-tokyo/DHTesp for DHT22
+#endif
#include
#include
@@ -67,7 +72,7 @@
#define SSD1306_ADDRESS 0x3C
// AXP192 address
-#define AXP192_SLAVE_ADDRESS 0x34
+// #define AXP192_SLAVE_ADDRESS 0x34 // already defined in axp20x.h
/* for feather32u4
#define RFM95_CS 8
@@ -142,7 +147,8 @@ const byte RX_en = 0; //TX/RX enable 1W modul
// #define ModemConfig BG_RF95::Bw125Cr45Sf4096
-#define DHTPIN 25 // pin the DHT22 is connected to Pin25
+#define DHTPIN 25 // the DHT22 is connected to PIN25
+#define ONE_WIRE_BUS 25 // the DS18B20 is connected to PIN25
// Variables for APRS packaging
String Tcall; //your Call Sign for normal position reports
@@ -210,7 +216,13 @@ void writedisplaytext(String, String, String, String, String, String, int);
void setup_data(void);
-DHTesp dht;
+#ifdef DS18B20
+ OneWire oneWire(ONE_WIRE_BUS);
+ DallasTemperature sensors(&oneWire);
+#else
+ DHTesp dht; // Initialize DHT sensor for normal 16mhz Arduino
+#endif
+
// SoftwareSerial ss(RXPin, TXPin); // The serial connection to the GPS device
HardwareSerial ss(1); // TTGO has HW serial
@@ -265,7 +277,11 @@ void setup()
Serial.println("LoRa-APRS / Init / AXP192 Begin FAIL");
}
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON);
- axp.setPowerOutPut(AXP192_LDO3, AXP202_ON);
+ if (tracker_mode != WX_FIXED) {
+ axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); // switch on GPS in all modes except WX_FIXED
+ } else {
+ axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF); // switch off GPS in WX_FIXED mode
+ }
axp.setPowerOutPut(AXP192_DCDC2, AXP202_ON);
axp.setPowerOutPut(AXP192_EXTEN, AXP202_ON);
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
@@ -369,6 +385,9 @@ void setup()
}
writedisplaytext(" "+Tcall,"","Init:","Data from GPS OK!","","",250);
Serial.println("LoRa-APRS / Init / Data from GPS OK!");
+ } else {
+ writedisplaytext(" "+Tcall,"","Init:","GPS switched OFF!","","",250);
+ Serial.println("LoRa-APRS / Init / GPS switched OFF!");
}
#ifdef T_BEAM_V1_0
@@ -387,10 +406,19 @@ void setup()
rf95.setModemConfig(BG_RF95::Bw125Cr45Sf4096); // hard coded because of double definition
rf95.setTxPower(5);
- dht.setup(DHTPIN,dht.AUTO_DETECT); // initialize DHT22
+ #ifdef DS18B20
+ sensors.begin();
+ #else
+ dht.setup(DHTPIN,dht.AUTO_DETECT); // initialize DHT22
+ #endif
delay(250);
- temp = dht.getTemperature();
- hum = dht.getHumidity();
+ #ifdef DS18B20
+ sensors.requestTemperatures(); // Send the command to get temperature readings
+ temp = sensors.getTempCByIndex(0); // get temp from 1st (!) sensor only
+ #else
+ temp = dht.getTemperature();
+ hum = dht.getHumidity();
+ #endif
writedisplaytext("LoRa-APRS","","Init:","DHT OK!","TEMP: "+String(temp,1),"HUM: "+String(hum,1),250);
Serial.print("LoRa-APRS / Init / DHT OK! Temp=");
Serial.print(String(temp));
@@ -426,6 +454,9 @@ void loop() {
tracker_mode = WX_FIXED;
writedisplaytext("LoRa-APRS","","New Mode","WX-FIXED","","",500);
Serial.println("LoRa-APRS / New Mode / WX-FIXED");
+ #ifdef T_BEAM_V1_0
+ axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF); // switch OFF GPS at mode WX_FIXED
+ #endif
blinker(4);
break;
case WX_FIXED:
@@ -433,6 +464,9 @@ void loop() {
tracker_mode = TRACKER;
writedisplaytext("LoRa-APRS","","New Mode","TRACKER","","",500);
Serial.println("LoRa-APRS / New Mode / TRACKER");
+ #ifdef T_BEAM_V1_0
+ axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); // switch on GPS in all modes except WX_FIXED
+ #endif
blinker(1);
break;
}
@@ -440,6 +474,7 @@ void loop() {
prefs.putChar("tracker_mode", (char)tracker_mode);
prefs.end();
button_ctr=0;
+ // ESP.restart();
}
} else {
button_ctr = 0;
@@ -447,14 +482,25 @@ void loop() {
if (hum_temp) {
hum_temp=false;
- temp = dht.getTemperature();
+ #ifdef DS18B20
+ sensors.requestTemperatures(); // Send the command to get temperature readings
+ temp = sensors.getTempCByIndex(0); // get temp from 1st (!) sensor only
+ #else
+ temp = dht.getTemperature();
+ #endif
} else {
hum_temp=true;
- hum = dht.getHumidity();
+ #ifdef DS18B20
+ hum = 0;
+ #else
+ hum = dht.getHumidity();
+ #endif
}
- while (ss.available() > 0) {
- gps.encode(ss.read());
+ if (tracker_mode != WX_FIXED) {
+ while (ss.available() > 0) {
+ gps.encode(ss.read());
+ }
}
if (rf95.waitAvailableTimeout(100)) {
@@ -475,6 +521,30 @@ void loop() {
if (nextTX < min_time_to_nextTX) {nextTX=min_time_to_nextTX;}
if (nextTX > max_time_to_nextTX) {nextTX=max_time_to_nextTX;}
+ average_course[point_avg_course] = gps.course.deg(); // calculate smart beaconing course
+ ++point_avg_course;
+ if (point_avg_course>2) {
+ point_avg_course=0;
+ // new_course = (average_course[0]+average_course[1]+average_course[2])/3;
+ new_course = atan ((sin(average_course[0])+sin(average_course[1])+sin(average_course[2]))/(cos(average_course[0])+cos(average_course[1])+cos(average_course[2])));
+ if ((old_course < 30) && (new_course > 330)) {
+ if (abs(new_course-old_course-360)>=30) {
+ nextTX = 0;
+ }
+ } else {
+ if ((old_course > 330) && (new_course < 30)) {
+ if (abs(new_course-old_course+360)>=30) {
+ nextTX = 0;
+ }
+ } else {
+ if (abs(new_course-old_course)>=30) {
+ nextTX = 0;
+ }
+ }
+ }
+ old_course = new_course;
+ }
+
} else {
LatShown = LatFixed;
LongShown = LongFixed;
@@ -487,18 +557,6 @@ void loop() {
nextTX = 0;
}
- average_course[point_avg_course] = gps.course.deg(); // calculate smart beaconing course
- ++point_avg_course;
- if (point_avg_course>2) {
- point_avg_course=0;
- new_course = (average_course[0]+average_course[1]+average_course[2])/3;
- if (abs(new_course-old_course)>=30) {
- nextTX = 0;
- }
- old_course = new_course;
- }
-
-
if ((millis()