Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20241217 feat lilygo t3s3 #122

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
"RadioLib@7.1.0"
"BresserWeatherSensorReceiver@0.30.0"
"RadioLib@7.1.1"
"LoRa Serialization@3.3.1"
"ESP32Time@2.0.6"
"OneWireNg@0.13.3"
Expand Down
65 changes: 60 additions & 5 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
// setup the radio for LoRaWAN
log_v("Initalise radio");

state = radio.begin();
debug(state != RADIOLIB_ERR_NONE, "Initalise 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
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
Loading