├── .gitignore ├── 1.png ├── LoRa ├── LoRa.ino ├── board_def.h ├── ds3231.cpp └── ds3231.h ├── README.MD ├── ReceiverBin ├── Receiver_V1_0_868.bin ├── Receiver_V1_2_433.bin ├── Receiver_V1_2_868.bin └── Recv.png └── SenderBin ├── Sender.png ├── Sender_V1_0_868.bin ├── Sender_V1_2_433.bin └── Sender_V1_2_868.bin /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | build 3 | .vscode 4 | _temp_by_dltool 5 | -------------------------------------------------------------------------------- /1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-LoRa-Series/757fb06abc0f3f83b022837e201a89b3faa4a1e5/1.png -------------------------------------------------------------------------------- /LoRa/LoRa.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ds3231.h" 4 | #include 5 | #include 6 | 7 | OLED_CLASS_OBJ display(OLED_ADDRESS, OLED_SDA, OLED_SCL); 8 | 9 | #define WIFI_SSID "Xiaomi" 10 | #define WIFI_PASSWORD "12345678" 11 | 12 | void setup() 13 | { 14 | Serial.begin(115200); 15 | while (!Serial); 16 | 17 | if (OLED_RST > 0) { 18 | pinMode(OLED_RST, OUTPUT); 19 | digitalWrite(OLED_RST, HIGH); 20 | delay(100); 21 | digitalWrite(OLED_RST, LOW); 22 | delay(100); 23 | digitalWrite(OLED_RST, HIGH); 24 | } 25 | 26 | display.init(); 27 | display.flipScreenVertically(); 28 | display.clear(); 29 | display.setFont(ArialMT_Plain_16); 30 | display.setTextAlignment(TEXT_ALIGN_CENTER); 31 | display.drawString(display.getWidth() / 2, display.getHeight() / 2, LORA_SENDER ? "LoRa Sender" : "LoRa Receiver"); 32 | display.display(); 33 | delay(2000); 34 | 35 | if (SDCARD_CS > 0) { 36 | display.clear(); 37 | SPIClass sdSPI(VSPI); 38 | sdSPI.begin(SDCARD_SCLK, SDCARD_MISO, SDCARD_MOSI, SDCARD_CS); 39 | if (!SD.begin(SDCARD_CS, sdSPI)) { 40 | display.drawString(display.getWidth() / 2, display.getHeight() / 2, "SDCard FAIL"); 41 | } else { 42 | display.drawString(display.getWidth() / 2, display.getHeight() / 2 - 16, "SDCard PASS"); 43 | uint32_t cardSize = SD.cardSize() / (1024 * 1024); 44 | display.drawString(display.getWidth() / 2, display.getHeight() / 2, "Size: " + String(cardSize) + "MB"); 45 | } 46 | display.display(); 47 | delay(2000); 48 | } 49 | 50 | 51 | String info = ds3231_test(); 52 | if (info != "") { 53 | display.clear(); 54 | display.setFont(ArialMT_Plain_16); 55 | display.setTextAlignment(TEXT_ALIGN_CENTER); 56 | display.drawString(display.getWidth() / 2, display.getHeight() / 2, info); 57 | display.display(); 58 | delay(2000); 59 | } 60 | 61 | WiFi.begin(WIFI_SSID, WIFI_PASSWORD); 62 | if (WiFi.waitForConnectResult() != WL_CONNECTED) { 63 | display.clear(); 64 | Serial.println("WiFi Connect Fail"); 65 | display.drawString(display.getWidth() / 2, display.getHeight() / 2, "WiFi Connect Fail"); 66 | display.display(); 67 | delay(2000); 68 | esp_restart(); 69 | } 70 | Serial.print("Connected : "); 71 | Serial.println(WiFi.SSID()); 72 | Serial.print("IP:"); 73 | Serial.println(WiFi.localIP().toString()); 74 | display.clear(); 75 | display.drawString(display.getWidth() / 2, display.getHeight() / 2, "IP:" + WiFi.localIP().toString()); 76 | display.display(); 77 | delay(2000); 78 | 79 | SPI.begin(CONFIG_CLK, CONFIG_MISO, CONFIG_MOSI, CONFIG_NSS); 80 | LoRa.setPins(CONFIG_NSS, CONFIG_RST, CONFIG_DIO0); 81 | if (!LoRa.begin(BAND)) { 82 | Serial.println("Starting LoRa failed!"); 83 | while (1); 84 | } 85 | if (!LORA_SENDER) { 86 | display.clear(); 87 | display.drawString(display.getWidth() / 2, display.getHeight() / 2, "LoraRecv Ready"); 88 | display.display(); 89 | } 90 | } 91 | 92 | int count = 0; 93 | 94 | void loop() 95 | { 96 | #if LORA_SENDER 97 | int32_t rssi; 98 | if (WiFi.status() == WL_CONNECTED) { 99 | rssi = WiFi.RSSI(); 100 | display.clear(); 101 | display.setTextAlignment(TEXT_ALIGN_CENTER); 102 | display.drawString(display.getWidth() / 2, display.getHeight() / 2, "Send RSSI:" + String(rssi)); 103 | display.display(); 104 | LoRa.beginPacket(); 105 | LoRa.print("WiFi RSSI: "); 106 | LoRa.print(rssi); 107 | LoRa.endPacket(); 108 | } else { 109 | Serial.println("WiFi Connect lost ..."); 110 | } 111 | delay(2500); 112 | #else 113 | if (LoRa.parsePacket()) { 114 | String recv = ""; 115 | while (LoRa.available()) { 116 | recv += (char)LoRa.read(); 117 | } 118 | count++; 119 | display.clear(); 120 | display.drawString(display.getWidth() / 2, display.getHeight() / 2, recv); 121 | String info = "[" + String(count) + "]" + "RSSI " + String(LoRa.packetRssi()); 122 | display.drawString(display.getWidth() / 2, display.getHeight() / 2 - 16, info); 123 | display.display(); 124 | } 125 | #endif 126 | } 127 | -------------------------------------------------------------------------------- /LoRa/board_def.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define LORA_V1_0_OLED 0 4 | #define LORA_V1_2_OLED 0 5 | #define LORA_V1_6_OLED 0 6 | #define LORA_V2_0_OLED 1 7 | 8 | #define LORA_SENDER 0 9 | // #define LORA_SENDER 1 10 | 11 | // #define LORA_PERIOD 868 12 | // #define LORA_PERIOD 915 13 | #define LORA_PERIOD 433 14 | 15 | #if LORA_V1_0_OLED 16 | #include 17 | #include "SSD1306Wire.h" 18 | #define OLED_CLASS_OBJ SSD1306Wire 19 | #define OLED_ADDRESS 0x3C 20 | #define OLED_SDA 4 21 | #define OLED_SCL 15 22 | #define OLED_RST 16 23 | #define CONFIG_MOSI 27 24 | #define CONFIG_MISO 19 25 | #define CONFIG_CLK 5 26 | #define CONFIG_NSS 18 27 | #define CONFIG_RST 14 28 | #define CONFIG_DIO0 26 29 | // ! There are two versions of TTGO LoRa V1.0, 30 | // ! the 868 version uses the 3D WiFi antenna, and the 433 version uses the PCB antenna. 31 | // ! You need to change the frequency according to the board. 32 | 33 | #define SDCARD_MOSI -1 34 | #define SDCARD_MISO -1 35 | #define SDCARD_SCLK -1 36 | #define SDCARD_CS -1 37 | 38 | #elif LORA_V1_2_OLED 39 | //Lora V1.2 ds3231 40 | #include 41 | #include "SSD1306Wire.h" 42 | #define OLED_CLASS_OBJ SSD1306Wire 43 | #define OLED_ADDRESS 0x3C 44 | #define OLED_SDA 21 45 | #define OLED_SCL 22 46 | #define OLED_RST -1 47 | #define CONFIG_MOSI 27 48 | #define CONFIG_MISO 19 49 | #define CONFIG_CLK 5 50 | #define CONFIG_NSS 18 51 | #define CONFIG_RST 23 52 | #define CONFIG_DIO0 26 53 | 54 | #define SDCARD_MOSI -1 55 | #define SDCARD_MISO -1 56 | #define SDCARD_SCLK -1 57 | #define SDCARD_CS -1 58 | 59 | #define ENABLE_DS3231 60 | 61 | #elif LORA_V1_6_OLED 62 | #include 63 | #include "SSD1306Wire.h" 64 | #define OLED_CLASS_OBJ SSD1306Wire 65 | #define OLED_ADDRESS 0x3C 66 | #define OLED_SDA 21 67 | #define OLED_SCL 22 68 | #define OLED_RST -1 69 | 70 | #define CONFIG_MOSI 27 71 | #define CONFIG_MISO 19 72 | #define CONFIG_CLK 5 73 | #define CONFIG_NSS 18 74 | #define CONFIG_RST 23 75 | #define CONFIG_DIO0 26 76 | 77 | #define SDCARD_MOSI 15 78 | #define SDCARD_MISO 2 79 | #define SDCARD_SCLK 14 80 | #define SDCARD_CS 13 81 | 82 | #elif LORA_V2_0_OLED 83 | #include 84 | #include "SSD1306Wire.h" 85 | #define OLED_CLASS_OBJ SSD1306Wire 86 | #define OLED_ADDRESS 0x3C 87 | #define OLED_SDA 21 88 | #define OLED_SCL 22 89 | #define OLED_RST -1 90 | 91 | #define CONFIG_MOSI 27 92 | #define CONFIG_MISO 19 93 | #define CONFIG_CLK 5 94 | #define CONFIG_NSS 18 95 | #define CONFIG_RST 23 96 | #define CONFIG_DIO0 26 97 | 98 | #define SDCARD_MOSI 15 99 | #define SDCARD_MISO 2 100 | #define SDCARD_SCLK 14 101 | #define SDCARD_CS 13 102 | 103 | #else 104 | #error "please select board" 105 | #endif 106 | 107 | 108 | #if LORA_PERIOD == 433 109 | #define BAND 433E6 110 | #elif LORA_PERIOD == 868 111 | #define BAND 868E6 112 | #elif LORA_PERIOD == 915 113 | #define BAND 915E6 114 | #else 115 | #error "Please select the correct lora frequency" 116 | #endif 117 | -------------------------------------------------------------------------------- /LoRa/ds3231.cpp: -------------------------------------------------------------------------------- 1 | #include "ds3231.h" 2 | 3 | #ifdef ENABLE_DS3231 4 | #include 5 | 6 | RtcDS3231 rtc(Wire); 7 | 8 | String ds3231_test() 9 | { 10 | rtc.Begin(); 11 | RtcDateTime compiled = RtcDateTime(__DATE__, __TIME__); 12 | if (!rtc.IsDateTimeValid()) { 13 | rtc.SetDateTime(compiled); 14 | } 15 | if (!rtc.GetIsRunning()) { 16 | Serial.println("RTC was not actively running, starting now"); 17 | rtc.SetIsRunning(true); 18 | } 19 | RtcDateTime now = rtc.GetDateTime(); 20 | if (now < compiled) { 21 | Serial.println("RTC is older than compile time! (Updating DateTime)"); 22 | rtc.SetDateTime(compiled); 23 | } 24 | 25 | rtc.Enable32kHzPin(false); 26 | 27 | rtc.SetSquareWavePin(DS3231SquareWavePin_ModeAlarmOne); 28 | 29 | rtc.LatchAlarmsTriggeredFlags(); 30 | 31 | RtcTemperature temp = rtc.GetTemperature(); 32 | Serial.print("RTC Temp : "); 33 | temp.Print(Serial); 34 | Serial.println(); 35 | 36 | now = rtc.GetDateTime(); 37 | char datestring[20]; 38 | Serial.print("RTC Date : "); 39 | 40 | snprintf_P(datestring, 41 | sizeof(datestring) / sizeof(datestring[0]), 42 | PSTR("%02u/%02u/%04u"), 43 | now.Month(), 44 | now.Day(), 45 | now.Year()); 46 | 47 | return String(datestring); 48 | } 49 | #endif -------------------------------------------------------------------------------- /LoRa/ds3231.h: -------------------------------------------------------------------------------- 1 | #pragma onec 2 | #include "board_def.h" 3 | #ifdef ENABLE_DS3231 4 | String ds3231_test(); 5 | #else 6 | #define ds3231_test() "" 7 | #endif -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | TTGO LOAR Series 2 | ============================== 3 | ![](1.png) 4 | 5 | ## BOARD PINS 6 | | Name | V1.0 | V1.2(T-Fox) | V1.6 | V2.0 | 7 | | ----------- | ---- | ----------- | ---- | ---- | 8 | | OLED RST | 16 | N/A | N/A | N/A | 9 | | OLED SDA | 4 | 21 | 21 | 21 | 10 | | OLED SCL | 15 | 22 | 22 | 22 | 11 | | SDCard CS | N/A | N/A | 13 | 13 | 12 | | SDCard MOSI | N/A | N/A | 15 | 15 | 13 | | SDCard MISO | N/A | N/A | 2 | 2 | 14 | | SDCard SCLK | N/A | N/A | 14 | 14 | 15 | | DS3231 SDA | N/A | 21 | N/A | N/A | 16 | | DS3231 SCL | N/A | 22 | N/A | N/A | 17 | | LORA MOSI | 27 | 27 | 27 | 27 | 18 | | LORA MISO | 19 | 19 | 19 | 19 | 19 | | LORA SCLK | 5 | 5 | 5 | 5 | 20 | | LORA CS | 18 | 18 | 18 | 18 | 21 | | LORA RST | 14 | 23 | 23 | 23 | 22 | | LORA DIO0 | 26 | 26 | 26 | 26 | 23 | 24 | 25 | ## First 26 | 27 | - For the first time, change the macro definition in `board_def.h` according to the corresponding layout and screen, and change the version to be used to 1. 28 | ``` 29 | #define LORA_V1_0_OLED 0 30 | #define LORA_V1_2_OLED 0 31 | #define LORA_V1_6_OLED 0 32 | #define LORA_V2_0_OLED 1 33 | ``` 34 | 35 | - Set the corresponding macro definition according to the lora frequency of the actual module 36 | ``` 37 | #define LORA_PERIOD 433 38 | // #define LORA_PERIOD 868 39 | // #define LORA_PERIOD 915 40 | ``` 41 | 42 | - Sender definition `LORA_SENDER` is 1, 0 is receiving 43 | 44 | ## Install the following dependency library files: 45 | - [arduino-LoRa](https://github.com/sandeepmistry/arduino-LoRa) 46 | - [oled-ssd1306](https://github.com/ThingPulse/esp8266-oled-ssd1306) 47 | 48 | -------------------------------------------------------------------------------- /ReceiverBin/Receiver_V1_0_868.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-LoRa-Series/757fb06abc0f3f83b022837e201a89b3faa4a1e5/ReceiverBin/Receiver_V1_0_868.bin -------------------------------------------------------------------------------- /ReceiverBin/Receiver_V1_2_433.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-LoRa-Series/757fb06abc0f3f83b022837e201a89b3faa4a1e5/ReceiverBin/Receiver_V1_2_433.bin -------------------------------------------------------------------------------- /ReceiverBin/Receiver_V1_2_868.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-LoRa-Series/757fb06abc0f3f83b022837e201a89b3faa4a1e5/ReceiverBin/Receiver_V1_2_868.bin -------------------------------------------------------------------------------- /ReceiverBin/Recv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-LoRa-Series/757fb06abc0f3f83b022837e201a89b3faa4a1e5/ReceiverBin/Recv.png -------------------------------------------------------------------------------- /SenderBin/Sender.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-LoRa-Series/757fb06abc0f3f83b022837e201a89b3faa4a1e5/SenderBin/Sender.png -------------------------------------------------------------------------------- /SenderBin/Sender_V1_0_868.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-LoRa-Series/757fb06abc0f3f83b022837e201a89b3faa4a1e5/SenderBin/Sender_V1_0_868.bin -------------------------------------------------------------------------------- /SenderBin/Sender_V1_2_433.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-LoRa-Series/757fb06abc0f3f83b022837e201a89b3faa4a1e5/SenderBin/Sender_V1_2_433.bin -------------------------------------------------------------------------------- /SenderBin/Sender_V1_2_868.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-LoRa-Series/757fb06abc0f3f83b022837e201a89b3faa4a1e5/SenderBin/Sender_V1_2_868.bin --------------------------------------------------------------------------------