Skip to content

Commit a3d46a3

Browse files
authored
Merge pull request #62 from awolden/awolden/t3lora
Add LILYGO T-LoRa V2.1-1.6 firmware
2 parents 45a88dc + 0fc85b8 commit a3d46a3

File tree

6 files changed

+153
-1
lines changed

6 files changed

+153
-1
lines changed

examples/companion_radio/main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
#include <helpers/ESP32Board.h>
7373
#include <helpers/CustomSX1262Wrapper.h>
7474
static ESP32Board board;
75+
#elif defined(LILYGO_TLORA)
76+
#include <helpers/LilyGoTLoraBoard.h>
77+
#include <helpers/CustomSX1276Wrapper.h>
78+
static LilyGoTLoraBoard board;
7579
#elif defined(RAK_4631)
7680
#include <helpers/nrf52/RAK4631Board.h>
7781
#include <helpers/CustomSX1262Wrapper.h>
@@ -1191,6 +1195,9 @@ class MyMesh : public BaseChatMesh {
11911195

11921196
#if defined(NRF52_PLATFORM)
11931197
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
1198+
#elif defined(LILYGO_TLORA)
1199+
SPIClass spi;
1200+
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
11941201
#elif defined(P_LORA_SCLK)
11951202
SPIClass spi;
11961203
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);

examples/simple_repeater/main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676
#include <helpers/ESP32Board.h>
7777
#include <helpers/CustomSX1262Wrapper.h>
7878
static ESP32Board board;
79+
#elif defined(LILYGO_TLORA)
80+
#include <helpers/LilyGoTLoraBoard.h>
81+
#include <helpers/CustomSX1276Wrapper.h>
82+
static LilyGoTLoraBoard board;
7983
#elif defined(RAK_4631)
8084
#include <helpers/nrf52/RAK4631Board.h>
8185
#include <helpers/CustomSX1262Wrapper.h>
@@ -607,6 +611,9 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
607611

608612
#if defined(NRF52_PLATFORM)
609613
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
614+
#elif defined(LILYGO_TLORA)
615+
SPIClass spi;
616+
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
610617
#elif defined(P_LORA_SCLK)
611618
SPIClass spi;
612619
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);

examples/simple_room_server/main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
#include <helpers/ESP32Board.h>
8181
#include <helpers/CustomSX1262Wrapper.h>
8282
static ESP32Board board;
83+
#elif defined(LILYGO_TLORA)
84+
#include <helpers/LilyGoTLoraBoard.h>
85+
#include <helpers/CustomSX1276Wrapper.h>
86+
static LilyGoTLoraBoard board;
8387
#elif defined(RAK_4631)
8488
#include <helpers/nrf52/RAK4631Board.h>
8589
#include <helpers/CustomSX1262Wrapper.h>
@@ -669,6 +673,9 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
669673

670674
#if defined(NRF52_PLATFORM)
671675
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
676+
#elif defined(LILYGO_TLORA)
677+
SPIClass spi;
678+
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
672679
#elif defined(P_LORA_SCLK)
673680
SPIClass spi;
674681
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);

examples/simple_secure_chat/main.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666
#include <helpers/ESP32Board.h>
6767
#include <helpers/CustomSX1262Wrapper.h>
6868
static ESP32Board board;
69+
#elif defined(LILYGO_TLORA)
70+
#include <helpers/LilyGoTLoraBoard.h>
71+
#include <helpers/CustomSX1276Wrapper.h>
72+
static LilyGoTLoraBoard board;
6973
#elif defined(RAK_4631)
7074
#include <helpers/nrf52/RAK4631Board.h>
7175
#include <helpers/CustomSX1262Wrapper.h>
@@ -541,6 +545,9 @@ class MyMesh : public BaseChatMesh, ContactVisitor {
541545

542546
#if defined(NRF52_PLATFORM)
543547
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
548+
#elif defined(LILYGO_TLORA)
549+
SPIClass spi;
550+
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
544551
#elif defined(P_LORA_SCLK)
545552
SPIClass spi;
546553
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);

platformio.ini

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,31 @@ lib_deps =
345345
${Xiao_S3_WIO.lib_deps}
346346
densaugeo/base64 @ ~1.4.0
347347

348+
; =============
349+
[LilyGo_TLora_V2_1_1_6]
350+
extends = esp32_base
351+
board = ttgo-lora32-v1 ; LILYGO T-LoRa V2.1-1.6 ESP32 with SX1276
352+
build_unflags = -Os
353+
build_type = release ; Set build type to release
354+
board_build.partitions = min_spiffs.csv ; get around 4mb flash limit
355+
build_flags =
356+
${esp32_base.build_flags}
357+
-Os -ffunction-sections -fdata-sections ; Optimize for size
358+
-D LILYGO_TLORA ; LILYGO T-LoRa V2.1-1.6 ESP32 with SX1276
359+
-D P_LORA_DIO_0=26 ; SX1276 DIO0 interrupt pin
360+
-D P_LORA_DIO_1=33 ; SX1276 DIO1 interrupt pin
361+
-D P_LORA_NSS=18 ; Chip select - SS pin
362+
-D P_LORA_RESET=14 ; Reset pin
363+
-D P_LORA_SCLK=5 ; SPI clock
364+
-D P_LORA_MISO=19 ; SPI MISO
365+
-D P_LORA_MOSI=27 ; SPI MOSI
366+
-D P_LORA_TX_LED=2 ; LED pin for TX indication
367+
-D PIN_VBAT_READ=35 ; Battery voltage reading (analog pin)
368+
-D RADIO_CLASS=CustomSX1276
369+
-D ARDUINO_LOOP_STACK_SIZE=16384
370+
-D WRAPPER_CLASS=CustomSX1276Wrapper
371+
-D LORA_TX_POWER=20
372+
348373
; =============
349374
[LilyGo_T3S3_sx1262]
350375
extends = esp32_base
@@ -367,12 +392,86 @@ build_flags = ${esp32_base.build_flags}
367392
-D WRAPPER_CLASS=CustomSX1262Wrapper
368393
-D LORA_TX_POWER=22
369394

395+
396+
; === LILYGO T-LoRa V2.1-1.6 with SX1276 environments ===
397+
[env:LilyGo_TLora_V2_1_1_6_Repeater]
398+
extends = LilyGo_TLora_V2_1_1_6
399+
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/simple_repeater/main.cpp>
400+
build_flags =
401+
${LilyGo_TLora_V2_1_1_6.build_flags}
402+
-D ADVERT_NAME="\"TLora-V2.1-1.6 Repeater\""
403+
-D ADVERT_LAT=-37.0
404+
-D ADVERT_LON=145.0
405+
-D ADMIN_PASSWORD="\"password\""
406+
; -D MESH_PACKET_LOGGING=1
407+
; -D MESH_DEBUG=1
408+
; -D CORE_DEBUG_LEVEL=3
409+
410+
[env:LilyGo_TLora_V2_1_1_6_terminal_chat]
411+
extends = LilyGo_TLora_V2_1_1_6
412+
build_flags =
413+
${LilyGo_TLora_V2_1_1_6.build_flags}
414+
-D MAX_CONTACTS=100
415+
-D MAX_GROUP_CHANNELS=1
416+
; -D MESH_PACKET_LOGGING=1
417+
; -D MESH_DEBUG=1
418+
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/simple_secure_chat/main.cpp>
419+
lib_deps =
420+
${LilyGo_TLora_V2_1_1_6.lib_deps}
421+
densaugeo/base64 @ ~1.4.0
422+
423+
[env:LilyGo_TLora_V2_1_1_6_companion_radio_usb]
424+
extends = LilyGo_TLora_V2_1_1_6
425+
build_flags =
426+
${LilyGo_TLora_V2_1_1_6.build_flags}
427+
-D MAX_CONTACTS=100
428+
-D MAX_GROUP_CHANNELS=1
429+
; -D ENABLE_PRIVATE_KEY_IMPORT=1
430+
; -D ENABLE_PRIVATE_KEY_EXPORT=1
431+
; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1
432+
; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1
433+
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/companion_radio/main.cpp>
434+
lib_deps =
435+
${LilyGo_TLora_V2_1_1_6.lib_deps}
436+
densaugeo/base64 @ ~1.4.0
437+
438+
[env:LilyGo_TLora_V2_1_1_6_companion_radio_ble]
439+
extends = LilyGo_TLora_V2_1_1_6
440+
build_flags =
441+
${LilyGo_TLora_V2_1_1_6.build_flags}
442+
-D MAX_CONTACTS=100
443+
-D MAX_GROUP_CHANNELS=1
444+
-D BLE_PIN_CODE=123456
445+
; -D BLE_DEBUG_LOGGING=1
446+
; -D ENABLE_PRIVATE_KEY_IMPORT=1
447+
; -D ENABLE_PRIVATE_KEY_EXPORT=1
448+
; -D MESH_PACKET_LOGGING=1
449+
; -D MESH_DEBUG=1
450+
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<helpers/esp32/*.cpp> +<../examples/companion_radio/main.cpp>
451+
lib_deps =
452+
${LilyGo_TLora_V2_1_1_6.lib_deps}
453+
densaugeo/base64 @ ~1.4.0
454+
455+
[env:LilyGo_TLora_V2_1_1_6_room_server]
456+
extends = LilyGo_TLora_V2_1_1_6
457+
build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/simple_room_server/main.cpp>
458+
build_flags =
459+
${LilyGo_TLora_V2_1_1_6.build_flags}
460+
-D ADVERT_NAME="\"TLora-V2.1-1.6 Room\""
461+
-D ADVERT_LAT=-37.0
462+
-D ADVERT_LON=145.0
463+
-D ADMIN_PASSWORD="\"password\""
464+
-D ROOM_PASSWORD="\"hello\""
465+
; -D MESH_PACKET_LOGGING=1
466+
; -D MESH_DEBUG=1
467+
468+
; === LilyGo T3S3 with SX1262 environments ===
370469
[env:LilyGo_T3S3_sx1262_Repeater]
371470
extends = LilyGo_T3S3_sx1262
372471
build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} +<../examples/simple_repeater/main.cpp>
373472
build_flags =
374473
${LilyGo_T3S3_sx1262.build_flags}
375-
-D ADVERT_NAME="\"T3S3 Repeater\""
474+
-D ADVERT_NAME="\"T3S3-1262 Repeater\""
376475
-D ADVERT_LAT=-37.0
377476
-D ADVERT_LON=145.0
378477
-D ADMIN_PASSWORD="\"password\""
@@ -424,6 +523,7 @@ lib_deps =
424523
${LilyGo_T3S3_sx1262.lib_deps}
425524
densaugeo/base64 @ ~1.4.0
426525

526+
427527
; ----------------- NRF52 ---------------------
428528
[nrf52_base]
429529
extends = arduino_base

src/helpers/LilyGoTLoraBoard.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
3+
#include <Arduino.h>
4+
#include "ESP32Board.h"
5+
6+
// LILYGO T-LoRa V2.1-1.6 board with SX1276
7+
class LilyGoTLoraBoard : public ESP32Board {
8+
public:
9+
const char* getManufacturerName() const override {
10+
return "LILYGO T-LoRa V2.1-1.6";
11+
}
12+
13+
uint16_t getBattMilliVolts() override {
14+
analogReadResolution(12);
15+
16+
uint32_t raw = 0;
17+
for (int i = 0; i < 8; i++) {
18+
raw += analogReadMilliVolts(PIN_VBAT_READ);
19+
}
20+
raw = raw / 8;
21+
22+
return (2 * raw);
23+
}
24+
};

0 commit comments

Comments
 (0)