From 458bc8804110dfe698a09a8d7042796e60a9edec Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 28 Apr 2018 12:13:00 +0200 Subject: [PATCH] SF display & set Pin DIO2 to LMIC_unused_pin --- platformio.ini | 4 ++-- src/hal/heltec.h | 2 +- src/hal/lolin32_lora.h | 4 ++-- src/hal/lolin32lite_lora.h | 4 ++-- src/hal/lopy.h | 2 +- src/hal/lopy4.h | 2 +- src/hal/ttgov1.h | 2 +- src/hal/ttgov2.h | 2 +- src/main.cpp | 18 +++++++++++------- src/main.h | 6 ++++++ src/paxcounter.conf | 5 +++-- 11 files changed, 31 insertions(+), 20 deletions(-) diff --git a/platformio.ini b/platformio.ini index f780a017..5f249bba 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,9 +11,9 @@ ; ---> SELECT TARGET PLATFORM HERE! <--- [platformio] -env_default = heltec_wifi_lora_32 +;env_default = heltec_wifi_lora_32 ;env_default = ttgov1 -;env_default = ttgov2 +env_default = ttgov2 ;env_default = lopy ;env_default = lopy4 ;env_default = lolin32lite_lora diff --git a/src/hal/heltec.h b/src/hal/heltec.h index eb9aa31c..ed2e63db 100644 --- a/src/hal/heltec.h +++ b/src/hal/heltec.h @@ -17,7 +17,7 @@ #define RST 14 // ESP32 GPIO14 (Pin14) -- SX1276 NRESET (Pin7) Reset Trigger Input #define DIO0 26 // ESP32 GPIO26 (Pin15) -- SX1276 DIO0 (Pin8) used by LMIC for detecting LoRa RX_Done & TX_Done #define DIO1 33 // ESP32 GPIO33 (Pin13) -- SX1276 DIO1 (Pin9) used by LMIC for detecting LoRa RX_Timeout -#define DIO2 32 // ESP32 GPIO32 (Pin12) -- SX1276 DIO2 (Pin10) not used by LMIC for LoRa (Timeout for FSK only) +#define DIO2 LMIC_UNUSED_PIN // 32 ESP32 GPIO32 (Pin12) -- SX1276 DIO2 (Pin10) not used by LMIC for LoRa (Timeout for FSK only) // Hardware pin definitions for Heltec LoRa-32 Board with OLED SSD1306 I2C Display #define OLED_RST 16 // ESP32 GPIO16 (Pin16) -- SD1306 RST diff --git a/src/hal/lolin32_lora.h b/src/hal/lolin32_lora.h index a1bdbe09..ca5929af 100644 --- a/src/hal/lolin32_lora.h +++ b/src/hal/lolin32_lora.h @@ -25,8 +25,8 @@ #define RST 25 // ESP32 GPIO25 (Pin25) -- SX1276 NRESET (Pin7) Reset Trigger Input #define DIO0 27 // ESP32 GPIO27 (Pin27) -- SX1276 DIO0 (Pin8) used by LMIC for detecting LoRa RX_Done & TX_Done #define DIO1 26 // ESP32 GPIO26 (Pin26) -- SX1276 DIO1 (Pin9) used by LMIC for detecting LoRa RX_Timeout -#define DIO2 4 // ESP32 GPIO4 (Pin4) -- SX1276 DIO2 (Pin10) not used by LMIC for LoRa (Timeout for FSK only) -#define DIO5 35 // ESP32 GPIO35 (Pin35) -- SX1276 DIO5 not used by LMIC for LoRa (Timeout for FSK only) +#define DIO2 LMIC_UNUSED_PIN // 4 ESP32 GPIO4 (Pin4) -- SX1276 DIO2 (Pin10) not used by LMIC for LoRa (Timeout for FSK only) +#define DIO5 LMIC_UNUSED_PIN // 35 ESP32 GPIO35 (Pin35) -- SX1276 DIO5 not used by LMIC for LoRa (Timeout for FSK only) // Hardware pin definitions for LoRaNode32 Board with OLED I2C Display #define OLED_RST U8X8_PIN_NONE // Not reset pin diff --git a/src/hal/lolin32lite_lora.h b/src/hal/lolin32lite_lora.h index fe2adac8..51cd6f10 100644 --- a/src/hal/lolin32lite_lora.h +++ b/src/hal/lolin32lite_lora.h @@ -24,8 +24,8 @@ #define RST 25 // ESP32 GPIO25 (Pin25) -- SX1276 NRESET (Pin7) Reset Trigger Input #define DIO0 27 // ESP32 GPIO27 (Pin27) -- SX1276 DIO0 (Pin8) used by LMIC for detecting LoRa RX_Done & TX_Done #define DIO1 26 // ESP32 GPIO26 (Pin26) -- SX1276 DIO1 (Pin9) used by LMIC for detecting LoRa RX_Timeout -#define DIO2 4 // ESP32 GPIO4 (Pin4) -- SX1276 DIO2 (Pin10) not used by LMIC for LoRa (Timeout for FSK only) -#define DIO5 35 // ESP32 GPIO35 (Pin35) -- SX1276 DIO5 not used by LMIC for LoRa (Timeout for FSK only) +#define DIO2 LMIC_UNUSED_PIN // 4 ESP32 GPIO4 (Pin4) -- SX1276 DIO2 (Pin10) not used by LMIC for LoRa (Timeout for FSK only) +#define DIO5 LMIC_UNUSED_PIN // 35 ESP32 GPIO35 (Pin35) -- SX1276 DIO5 not used by LMIC for LoRa (Timeout for FSK only) // Hardware pin definitions for LoRaNode32 Board with OLED I2C Display #define OLED_RST U8X8_PIN_NONE // Not reset pin diff --git a/src/hal/lopy.h b/src/hal/lopy.h index fffb2294..3e34dc8f 100644 --- a/src/hal/lopy.h +++ b/src/hal/lopy.h @@ -12,7 +12,7 @@ #define RST 18 #define DIO0 23 // LoRa IRQ #define DIO1 23 // workaround -#define DIO2 23 // workaround +#define DIO2 LMIC_UNUSED_PIN // 23 workaround // select WIFI antenna (internal = onboard / external = u.fl socket) #define HAS_ANTENNA_SWITCH 16 // pin for switching wifi antenna diff --git a/src/hal/lopy4.h b/src/hal/lopy4.h index 4ff9ac72..223e26b5 100644 --- a/src/hal/lopy4.h +++ b/src/hal/lopy4.h @@ -12,7 +12,7 @@ #define RST LMIC_UNUSED_PIN #define DIO0 23 // LoRa IRQ #define DIO1 23 // workaround -#define DIO2 23 // workaround +#define DIO2 LMIC_UNUSED_PIN // 23 workaround // select WIFI antenna (internal = onboard / external = u.fl socket) #define HAS_ANTENNA_SWITCH 21 // pin for switching wifi antenna diff --git a/src/hal/ttgov1.h b/src/hal/ttgov1.h index ab6b4f2c..c8e1a12d 100644 --- a/src/hal/ttgov1.h +++ b/src/hal/ttgov1.h @@ -18,7 +18,7 @@ #define RST 14 // ESP32 GPIO14 (Pin14) -- SX1276 NRESET (Pin7) Reset Trigger Input #define DIO0 26 // ESP32 GPIO26 (Pin15) -- SX1276 DIO0 (Pin8) used by LMIC for detecting LoRa RX_Done & TX_Done #define DIO1 33 // ESP32 GPIO33 (Pin13) -- SX1276 DIO1 (Pin9) used by LMIC for detecting LoRa RX_Timeout -#define DIO2 32 // ESP32 GPIO32 (Pin12) -- SX1276 DIO2 (Pin10) not used by LMIC for LoRa (Timeout for FSK only) +#define DIO2 LMIC_UNUSED_PIN // 32 ESP32 GPIO32 (Pin12) -- SX1276 DIO2 (Pin10) not used by LMIC for LoRa (Timeout for FSK only) // Hardware pin definitions for TTGOv1 Board with OLED SSD1306 I2C Display #define OLED_RST 16 // ESP32 GPIO16 (Pin16) -- SD1306 Reset diff --git a/src/hal/ttgov2.h b/src/hal/ttgov2.h index 537990af..ebdfe87d 100644 --- a/src/hal/ttgov2.h +++ b/src/hal/ttgov2.h @@ -19,7 +19,7 @@ #define RST LMIC_UNUSED_PIN // connected to ESP32 RST/EN #define DIO0 26 // ESP32 GPIO26 wired on PCB to HPD13A #define DIO1 33 // HPDIO1 on pcb, needs to be wired external to GPIO33 -#define DIO2 32 // HPDIO2 on pcb, needs to be wired external to GPIO32 (not necessary for LoRa, only FSK) +#define DIO2 LMIC_UNUSED_PIN // 32 HPDIO2 on pcb, needs to be wired external to GPIO32 (not necessary for LoRa, only FSK) // Hardware pin definitions for TTGO V2 Board with OLED SSD1306 0,96" I2C Display #define OLED_RST U8X8_PIN_NONE // connected to CPU RST/EN diff --git a/src/main.cpp b/src/main.cpp index 75187849..3dd674b4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -330,16 +330,20 @@ uint64_t uptime() { u8x8.printf("%-16s", "BLTH:off"); #endif - // update free memory display (line 4) - u8x8.setCursor(10,4); - u8x8.printf("%4dKB", ESP.getFreeHeap() / 1024); + // update LoRa SF display (line 3) + u8x8.setCursor(11,3); + u8x8.printf("SF:%c%c", lora_datarate[LMIC.datarate * 2], lora_datarate[LMIC.datarate * 2 + 1]); - // update RSSI limiter status & wifi channel display (line 5) - u8x8.setCursor(0,5); - u8x8.printf(!cfg.rssilimit ? "RLIM:off " : "RLIM:%-4d", cfg.rssilimit); - u8x8.setCursor(11,5); + // update wifi channel display (line 4) + u8x8.setCursor(11,4); u8x8.printf("ch:%02d", channel); + // update RSSI limiter status & free memory display (line 5) + u8x8.setCursor(0,5); + u8x8.printf(!cfg.rssilimit ? "RLIM:off " : "RLIM:%-4d", cfg.rssilimit); + u8x8.setCursor(10,5); + u8x8.printf("%4dKB", ESP.getFreeHeap() / 1024); + // update LoRa status display (line 6) u8x8.setCursor(0,6); u8x8.printf("%-16s", display_lora); diff --git a/src/main.h b/src/main.h index 48390d7e..7bdc094e 100644 --- a/src/main.h +++ b/src/main.h @@ -10,6 +10,12 @@ enum led_states { LED_ON }; +#if defined(CFG_eu868) + const char lora_datarate[] = {"1211100908077BFSNA"}; +#elif defined(CFG_us915) + const char lora_datarate[] = {"100908078CNA121110090807"}; +#endif + //--- Prototypes --- // defined in main.cpp diff --git a/src/paxcounter.conf b/src/paxcounter.conf index 584e1ab4..16fbae40 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -33,7 +33,8 @@ #define WIFI_CHANNEL_SWITCH_INTERVAL 50 // [seconds/100] -> 0,5 sec. // LoRa payload send cycle --> take care of duty cycle of LoRaWAN network! <-- -#define SEND_SECS 120 // [seconds/2] -> 240 sec. +//#define SEND_SECS 120 // [seconds/2] -> 240 sec. +#define SEND_SECS 30 #define MEM_LOW 2048 // [Bytes] memory threshold triggering send cycle // Default LoRa Spreadfactor @@ -73,7 +74,7 @@ // enable more verbose output. Make sure that printf is actually // configured (e.g. on AVR it is not by default), otherwise using it can // cause crashing. -//#define LMIC_DEBUG_LEVEL 1 +#define LMIC_DEBUG_LEVEL 1 // Enable this to allow using printf() to print to the given serial port // (or any other Print object). This can be easy for debugging. The