Skip to content

Commit

Permalink
20241217 feat lilygo t3s3 (#122)
Browse files Browse the repository at this point in the history
Changed to use radio object from BresserWeatherSensorReceiver
Added support for LilyGo T3 S3 SX1262/LR1121
  • Loading branch information
matthias-bs authored Jan 2, 2025
1 parent efa4e92 commit 88a1369
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 11 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
#- esp32:esp32:ttgo-lora32:Revision=TTGO_LoRa32_V1
#- esp32:esp32:ttgo-lora32:Revision=TTGO_LoRa32_V2
- esp32:esp32:ttgo-lora32:Revision=TTGO_LoRa32_v21new
- esp32:esp32:lilygo_t3s3:Revision=Radio_LR1121
#- esp32:esp32:heltec_wireless_stick:PSRAM=disabled
#- esp32:esp32:heltec_wifi_lora_32_V2
- esp32:esp32:heltec_wifi_lora_32_V3
Expand Down Expand Up @@ -76,8 +77,8 @@ jobs:
|
#declare -a required_libs=("https://github.com/matthias-bs/BresserWeatherSensorReceiver.git"
declare -a required_libs=(
"BresserWeatherSensorReceiver@0.28.10"
"[email protected].0"
"BresserWeatherSensorReceiver@0.30.0"
"[email protected].1"
"LoRa [email protected]"
"[email protected]"
"[email protected]"
Expand Down
61 changes: 58 additions & 3 deletions BresserWeatherSensorLW.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// BresserWeatherSensorLW.ino
//
// Bresser 868 MHz Weather Sensor Radio Receiver
// based on ESP32 and RFM95W/SX1276/SX1262 -
// based on ESP32 and RFM95W/SX1276/SX1262/LR1121 -
// sends data to a LoRaWAN network (e.g. The Things Network)
//
// The radio transceiver is used with RadioLib
Expand All @@ -25,10 +25,10 @@
// Library dependencies (tested versions):
// ---------------------------------------
// (install via normal Arduino Library installer:)
// RadioLib 7.1.0
// RadioLib 7.1.1
// LoRa_Serialization 3.3.1
// ESP32Time 2.0.6
// BresserWeatherSensorReceiver 0.28.10
// BresserWeatherSensorReceiver 0.30.0
// OneWireNg 0.13.3 (optional)
// DallasTemperature 3.9.0 (optional)
// NimBLE-Arduino 1.4.2 (optional)
Expand Down Expand Up @@ -109,6 +109,7 @@
// Moved start of sensor reception after battery voltage check
// Modified sleep duration if battery is low but external power is available
// 20241227 Moved uplinkDelay() from BresserWeatherSensorLWCmd.cpp
// Changed to use radio object from BresserWeatherSensorReceiver
//
// ToDo:
// -
Expand Down Expand Up @@ -190,6 +191,40 @@ using namespace PowerFeather;
#include "src/AppLayer.h"
#include "src/adc/adc.h"

#if defined(RADIO_CHIP)
// Use radio object from BresserWeatherSensorReceiver
extern RADIO_CHIP radio;

#else
// Create radio object
LORA_CHIP radio = new Module(PIN_LORA_NSS, PIN_LORA_IRQ, PIN_LORA_RST, PIN_LORA_GPIO);

#if defined(ARDUINO_LILYGO_T3S3_SX1262) || defined(ARDUINO_LILYGO_T3S3_SX1276) || defined(ARDUINO_LILYGO_T3S3_LR1121)
SPIClass *spi = nullptr;
#endif
#endif



#if defined(ARDUINO_LILYGO_T3S3_LR1121)
static const uint32_t rfswitch_dio_pins[] = {
RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6,
RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC
};

static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6
{ LR11x0::MODE_STBY, { LOW, LOW } },
{ LR11x0::MODE_RX, { HIGH, LOW } },
{ LR11x0::MODE_TX, { LOW, HIGH } },
{ LR11x0::MODE_TX_HP, { LOW, HIGH } },
{ LR11x0::MODE_TX_HF, { LOW, LOW } },
{ LR11x0::MODE_GNSS, { LOW, LOW } },
{ LR11x0::MODE_WIFI, { LOW, LOW } },
END_OF_MODE_TABLE,
};
#endif // ARDUINO_LILYGO_T3S3_LR1121

// Time zone info
const char *TZ_INFO = TZINFO_STR;

Expand Down Expand Up @@ -646,13 +681,33 @@ void setup()

int16_t state = 0; // return value for calls to RadioLib

#if !defined(RADIO_CHIP)
#if defined(ARDUINO_LILYGO_T3S3_SX1262) || defined(ARDUINO_LILYGO_T3S3_SX1276) || defined(ARDUINO_LILYGO_T3S3_LR1121)
// Use local radio object with custom SPI configuration
spi = new SPIClass(SPI);
spi->begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
radio = new Module(PIN_RECEIVER_CS, PIN_RECEIVER_IRQ, PIN_RECEIVER_RST, PIN_RECEIVER_GPIO, *spi);
#endif
#endif

radio.reset();
LoRaWANNode node(&radio, &Region, subBand);

// setup the radio based on the pinmap (connections) in config.h
log_v("Initialise radio");

state = radio.begin();
debug(state != RADIOLIB_ERR_NONE, "Initialise radio failed", state, true);


// Using local radio object
#if defined(ARDUINO_LILYGO_T3S3_LR1121)
radio.setRfSwitchTable(rfswitch_dio_pins, rfswitch_table);

// LR1121 TCXO Voltage 2.85~3.15V
radio.setTCXO(3.0);
#endif

// activate node by restoring session or otherwise joining the network
state = lwActivate(node);
// state is one of RADIOLIB_LORAWAN_NEW_SESSION or RADIOLIB_LORAWAN_SESSION_RESTORED
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ See [Parameters](#parameters) for more details.
| :hourglass: | [LILYGO®TTGO-LORA32 V1](https://github.com/Xinyuan-LilyGo/TTGO-LoRa-Series) | TTGO LoRa32-OLED /<br>TTGO LoRa32 V1 (No TFCard) | TTGO_LORA32_V1 | SX1276 (HPD13A) | - |
| :hourglass: | [LILYGO®TTGO-LORA32 V2](https://github.com/LilyGO/TTGO-LORA32) | TTGO LoRa32-OLED /<br>TTGO LoRa32 V2 | TTGO_LoRa32_V2 | SX1276 (HPD13A) | For LMIC only: Wire DIO1 to GPIO33 |
| :white_check_mark: | [LILYGO®TTGO-LORA32 V2.1](https://www.lilygo.cc/products/lora3?variant=42272562282677) | TTGO LoRa32-OLED /<br>TTGO LoRa32 V2.1 (1.6.1) | TTGO_LoRa32_v21new | SX1276 (HPD13A) | - |
| :white_check_mark: | [LILYGO®T3 S3 SX1262](https://lilygo.cc/products/t3s3-v1-0?variant=42586879721653) | "LilyGo T3-S3" / "Radio-SX1262" | LILYGO_T3S3_SX1262 | SX1262 | - |
| :white_check_mark: | [LILYGO®T3 S3 LR1121](https://lilygo.cc/products/t3-s3-lr1121) | "LilyGo T3-S3" / "Radio-LR1121" | LILYGO_T3S3_LR1121 | LR1121 | - |
| :hourglass: | [Heltec Wireless Stick](https://heltec.org/project/wireless-stick/) | Heltec Wireless Stick | HELTEC_WIRELESS_STICK | SX1276 | - |
| :hourglass: | [Heltec WiFi LoRa 32 V2](https://heltec.org/project/wifi-lora-32/) | Heltec WiFi LoRa 32(V2) | HELTEC_WIFI_LORA_32_V2 | SX1276 | - |
| :white_check_mark: | [Heltec WiFi LoRa 32 V3](https://heltec.org/project/wifi-lora-32-v3/) | Heltec WiFi LoRa 32(V3) | HELTEC_WIFI_LORA_32_V3 | SX1262 | - |
Expand Down
13 changes: 7 additions & 6 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
// 20240922 Bumped to RadioLib v7.0.0
// 20240928 Modified for LoRaWAN v1.0.4 (requires no nwkKey)
// 20241227 Modified radio chip selection
// Removed instances of radio and LoRaWANNode classes
//
// ToDo:
// -
Expand All @@ -56,6 +57,7 @@
#include <RadioLib.h>
#include "secrets.h"
#include "BresserWeatherSensorLWCfg.h"
#include "WeatherSensorCfg.h"

// How often to send an uplink - consider legal & FUP constraints - see notes
const uint32_t uplinkIntervalSeconds = 5UL * 60UL; // minutes x seconds
Expand Down Expand Up @@ -97,7 +99,7 @@ const uint8_t subBand = 0; // For US915, change this to 2, otherwise leave on 0
// If you get an error message when compiling, it may be that the
// pinmap could not be determined - see the notes for more info


#if !defined(RADIO_CHIP)
// Adafruit
#if defined(ARDUINO_FEATHER_ESP32) || defined(ARDUINO_THINGPULSE_EPULSE_FEATHER)
#define PIN_LORA_NSS 14
Expand Down Expand Up @@ -336,8 +338,10 @@ const uint8_t subBand = 0; // For US915, change this to 2, otherwise leave on 0
#else
#pragma message ("No radio chip selected")
#endif

LORA_CHIP radio = new Module(PIN_LORA_NSS, PIN_LORA_IRQ, PIN_LORA_RST, PIN_LORA_GPIO);
#else // RADIO_CHIP is defined in BresserWeatherSensorCfg.h
#pragma message("Using radio object from BresserWeatherSensorReceiver")
#define LORA_CHIP RADIO_CHIP
#endif

// Copy over the EUI's & keys in to the something that will not compile if incorrectly formatted
uint64_t joinEUI = RADIOLIB_LORAWAN_JOIN_EUI;
Expand All @@ -349,9 +353,6 @@ uint8_t nwkKey[] = { RADIOLIB_LORAWAN_NWK_KEY };
uint8_t nwkKey[] = { 0 };
#endif

// Create the LoRaWAN node
LoRaWANNode node(&radio, &Region, subBand);

// result code to text ...
String stateDecode(const int16_t result) {
switch (result) {
Expand Down

0 comments on commit 88a1369

Please sign in to comment.