diff --git a/.gitignore b/.gitignore index 03f4a3c..e0db434 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +.env .pio diff --git a/platformio.ini b/platformio.ini index 1d3415e..38b4de1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,6 +13,11 @@ platform = espressif32 board = heltec_wifi_lora_32_V2 framework = arduino +build_flags = + -D DEVEUI=\"${sysenv.DEVEUI}\" + -D APPEUI=\"${sysenv.APPEUI}\" + -D APPKEY=\"${sysenv.APPKEY}\" + lib_deps = Heltec ESP32 Dev-Boards@1.0.9 TTN_esp32@0.1.0 diff --git a/src/config.hh b/src/config.hh new file mode 100644 index 0000000..dc8fef6 --- /dev/null +++ b/src/config.hh @@ -0,0 +1,24 @@ +// Logic: Below charging voltage deep-sleep is used, above delay as +// battery is provided power +#define BATTERY_LOAD_VOLTAGE 13.5 // 14V SHOULD be supplied during charge +#define BATTERY_SLEEP_US 240 * 1000000 // 240s of deep sleep = 360 wake-ups / day +#define CHARGE_SLEEP_MS 30 * 1000 // 30s delay between measurements during charging + +// Debug: Allow to enable / disable LoRa sending / deep sleep +#define DISABLE_SLEEP false +#define ENABLE_SEND true + +// PIN to which the voltage sensor is connected +#define PIN_VOLTAGE_READ 32 + +// Adjustments for the measurement to work around unstable measurements +#define CORRECT_DIFF 0.90 // Measurement isn't fully accurate, lets adjust +#define MEAS_COUNT 16 // How many readings to make for each measurement + +// LoRaWAN configuration +#define BAND 868E6 // 868MHz = Europe transfer channel + +// Defined through environment variable during build, see platformio.ini +const char* devEui = DEVEUI; // TTN Device EUI +const char* appEui = APPEUI; // TTN Application EUI +const char* appKey = APPKEY; // TTN Application Key diff --git a/src/main.cpp b/src/main.cpp index 86da80a..c526ab9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,7 @@ #include #include "heltec.h" -#include "config.h" +#include "config.hh" #include "main.hh" #include "math.hh"