Skip to content

Commit 7669b97

Browse files
authored
Merge pull request #208 from cod3doomy/dev
updated: t-beam supreme sx1262 to be merged
2 parents 7b1582a + f64470c commit 7669b97

File tree

7 files changed

+443
-3
lines changed

7 files changed

+443
-3
lines changed

boards/t_beams3_supreme.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"build": {
3+
"arduino":{
4+
"ldscript": "esp32s3_out.ld",
5+
"partitions": "default.csv",
6+
"memory_type": "qio_qspi"
7+
},
8+
"core": "esp32",
9+
"extra_flags": [
10+
"-DARDUINO_USB_MODE=1",
11+
"-DARDUINO_USB_CDC_ON_BOOT=1",
12+
"-DARDUINO_RUNNING_CORE=1",
13+
"-DARDUINO_EVENT_RUNNING_CORE=1"
14+
],
15+
"f_cpu": "240000000L",
16+
"f_flash": "80000000L",
17+
"flash_mode": "qio",
18+
"hwids": [
19+
[
20+
"0x303A",
21+
"0x1001"
22+
]
23+
],
24+
"mcu": "esp32s3",
25+
"variant": "esp32s3"
26+
},
27+
"connectivity": [
28+
"wifi"
29+
],
30+
"debug": {
31+
"default_tool": "esp-builtin",
32+
"onboard_tools": [
33+
"esp-builtin"
34+
],
35+
"openocd_target": "esp32s3.cfg"
36+
},
37+
"frameworks": [
38+
"arduino",
39+
"espidf"
40+
],
41+
"name": "LilyGo T-Beam supreme (8MB Flash 8MB PSRAM)",
42+
"upload": {
43+
"flash_size": "8MB",
44+
"maximum_ram_size": 327680,
45+
"maximum_size": 8388608,
46+
"require_upload_port": true,
47+
"speed": 460800
48+
},
49+
"url": "https://www.lilygo.cc/products/t-beamsupreme-m",
50+
"vendor": "LilyGo"
51+
}

platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ build_flags = ${nrf52_base.build_flags}
5959
lib_deps =
6060
${nrf52_base.lib_deps}
6161
rweather/Crypto @ ^0.4.0
62-
https://github.com/adafruit/Adafruit_nRF52_Arduino
62+
https://github.com/adafruit/Adafruit_nRF52_Arduino

src/helpers/AutoDiscoverRTCClock.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
#include "AutoDiscoverRTCClock.h"
22
#include "RTClib.h"
33
#include <Melopero_RV3028.h>
4+
#include "pcf8563.h"
45

56
static RTC_DS3231 rtc_3231;
67
static bool ds3231_success = false;
78

89
static Melopero_RV3028 rtc_rv3028;
910
static bool rv3028_success = false;
1011

12+
static RTC_PCF8563 rtc_8563;
13+
static bool rtc_8563_success = false;
14+
1115
#define DS3231_ADDRESS 0x68
1216
#define RV3028_ADDRESS 0x52
17+
#define PCF8563_ADDRESS 0x51
1318

1419
bool AutoDiscoverRTCClock::i2c_probe(TwoWire& wire, uint8_t addr) {
1520
wire.beginTransmission(addr);
@@ -28,6 +33,9 @@ void AutoDiscoverRTCClock::begin(TwoWire& wire) {
2833
rtc_rv3028.set24HourMode(); // Set the device to use the 24hour format (default) instead of the 12 hour format
2934
rv3028_success = true;
3035
}
36+
if(i2c_probe(wire,PCF8563_ADDRESS)){
37+
rtc_8563_success = rtc_8563.begin(&wire);
38+
}
3139
}
3240

3341
uint32_t AutoDiscoverRTCClock::getCurrentTime() {
@@ -44,6 +52,9 @@ uint32_t AutoDiscoverRTCClock::getCurrentTime() {
4452
rtc_rv3028.getSecond()
4553
).unixtime();
4654
}
55+
if(rtc_8563_success){
56+
return rtc_8563.now().unixtime();
57+
}
4758
return _fallback->getCurrentTime();
4859
}
4960

@@ -52,9 +63,10 @@ void AutoDiscoverRTCClock::setCurrentTime(uint32_t time) {
5263
rtc_3231.adjust(DateTime(time));
5364
} else if (rv3028_success) {
5465
auto dt = DateTime(time);
55-
uint8_t weekday = (dt.day() + (uint16_t)((2.6 * dt.month()) - 0.2) - (2 * (dt.year() / 100)) + dt.year() + (uint16_t)(dt.year() / 4) + (uint16_t)(dt.year() / 400)) % 7;
56-
66+
uint8_t weekday = (dt.day() + (uint16_t)((2.6 * dt.month()) - 0.2) - (2 * (dt.year() / 100)) + dt.year() + (uint16_t)(dt.year() / 4) + (uint16_t)(dt.year() / 400)) % 7;
5767
rtc_rv3028.setTime(dt.year(), dt.month(), weekday, dt.day(), dt.hour(), dt.minute(), dt.second());
68+
} else if (rtc_8563_success) {
69+
rtc_8563.adjust(DateTime(time));
5870
} else {
5971
_fallback->setCurrentTime(time);
6072
}

src/helpers/TBeamS3SupremeBoard.h

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#pragma once
2+
3+
#include "ESP32Board.h"
4+
#include <driver/rtc_io.h>
5+
#include <Wire.h>
6+
#include <Arduino.h>
7+
#include "XPowersLib.h"
8+
9+
// LoRa radio module pins for TBeam S3 Supreme
10+
#define P_LORA_DIO_1 1 //SX1262 IRQ pin
11+
#define P_LORA_NSS 10 //SX1262 SS pin
12+
#define P_LORA_RESET 5 //SX1262 Rest pin
13+
#define P_LORA_BUSY 4 //SX1262 Busy pin
14+
#define P_LORA_SCLK 12 //SX1262 SCLK pin
15+
#define P_LORA_MISO 13 //SX1262 MISO pin
16+
#define P_LORA_MOSI 11 //SX1262 MOSI pin
17+
18+
#define PIN_BOARD_SDA 17 //SDA for OLED, BME280, and QMC6310U (0x1C)
19+
#define PIN_BOARD_SCL 18 //SCL for OLED, BME280, and QMC6310U (0x1C)
20+
21+
#define PIN_BOARD_SDA1 42 //SDA for PMU and PFC8563 (RTC)
22+
#define PIN_BOARD_SCL1 41 //SCL for PMU and PFC8563 (RTC)
23+
#define PIN_PMU_IRQ 40 //IRQ pin for PMU
24+
25+
#define PIN_USER_BTN 0
26+
27+
#define P_BOARD_SPI_MOSI 35 //SPI for SD Card and QMI8653 (IMU)
28+
#define P_BOARD_SPI_MISO 37 //SPI for SD Card and QMI8653 (IMU)
29+
#define P_BOARD_SPI_SCK 36 //SPI for SD Card and QMI8653 (IMU)
30+
#define P_BPARD_SPI_CS 47 //SPI for SD Card and QMI8653 (IMU)
31+
#define P_BOARD_IMU_CS 34 //Pin for QMI8653 (IMU) CS
32+
33+
#define P_BOARD_IMU_INT 33 //IMU Int pin
34+
#define P_BOARD_RTC_INT 14 //RTC Int pin
35+
36+
#define P_GPS_RX 9 //GPS RX pin
37+
#define P_GPS_TX 8 //GPS TX pin
38+
#define P_GPS_WAKE 7 //GPS Wakeup pin
39+
#define P_GPS_1PPS 6 //GPS 1PPS pin
40+
41+
//I2C Wire addresses
42+
#define I2C_BME280_ADD 0x76 //BME280 sensor I2C address on Wire
43+
#define I2C_OLED_ADD 0x3C //SH1106 OLED I2C address on Wire
44+
#define I2C_QMC6310U_ADD 0x1C //QMC6310U mag sensor I2C address on Wire
45+
46+
//I2C Wire1 addresses
47+
#define I2C_RTC_ADD 0x51 //RTC I2C address on Wire1
48+
#define I2C_PMU_ADD 0x34 //AXP2101 I2C address on Wire1
49+
50+
51+
52+
class TBeamS3SupremeBoard : public ESP32Board {
53+
54+
public:
55+
void begin() {
56+
57+
bool power_init();
58+
59+
ESP32Board::begin();
60+
61+
esp_reset_reason_t reason = esp_reset_reason();
62+
if (reason == ESP_RST_DEEPSLEEP) {
63+
long wakeup_source = esp_sleep_get_ext1_wakeup_status();
64+
if (wakeup_source & (1 << P_LORA_DIO_1)) { // received a LoRa packet (while in deep sleep)
65+
startup_reason = BD_STARTUP_RX_PACKET;
66+
}
67+
68+
rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS);
69+
rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_1);
70+
}
71+
}
72+
73+
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
74+
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
75+
76+
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
77+
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
78+
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
79+
80+
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
81+
82+
if (pin_wake_btn < 0) {
83+
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
84+
} else {
85+
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
86+
}
87+
88+
if (secs > 0) {
89+
esp_sleep_enable_timer_wakeup(secs * 1000000);
90+
}
91+
92+
// Finally set ESP32 into sleep
93+
esp_deep_sleep_start(); // CPU halts here and never returns!
94+
}
95+
96+
uint16_t getBattMilliVolts() override {
97+
98+
return 0;
99+
}
100+
101+
uint16_t getBattPercent();
102+
103+
const char* getManufacturerName() const override {
104+
return "LilyGo T-Beam S3 Supreme SX1262";
105+
}
106+
};
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
[T_Beam_S3_Supreme_SX1262]
2+
extends = esp32_base
3+
board = t_beams3_supreme ; LILYGO T-Beam Supreme ESP32S3 with SX1262
4+
build_flags =
5+
${esp32_base.build_flags}
6+
-I variants/lilygo_tbeam_supreme_SX1262
7+
-D LORA_TX_POWER=22
8+
-D RADIO_CLASS=CustomSX1262
9+
-D WRAPPER_CLASS=CustomSX1262Wrapper
10+
;-D DISPLAY_CLASS=SSD1306Display ;Needs to be modified for SH1106
11+
-D SX126X_RX_BOOSTED_GAIN=1
12+
build_src_filter = ${esp32_base.build_src_filter}
13+
+<../variants/lilygo_tbeam_supreme_SX1262>
14+
board_build.partitions = min_spiffs.csv ; get around 4mb flash limit
15+
lib_deps =
16+
${esp32_base.lib_deps}
17+
lewisxhe/PCF8563_Library@^1.0.1
18+
lewisxhe/XPowersLib @ ^0.2.7
19+
;adafruit/Adafruit SSD1306 @ ^2.5.13
20+
21+
; === LILYGO T-Beam S3 Supreme with SX1262 environments ===
22+
[env:T_Beam_S3_Supreme_SX1262_repeater]
23+
extends = T_Beam_S3_Supreme_SX1262
24+
build_flags =
25+
${T_Beam_S3_Supreme_SX1262.build_flags}
26+
-D ADVERT_NAME='"T-Beam S3 Supreme SX1262 Repeater"'
27+
-D ADVERT_LAT=0
28+
-D ADVERT_LON=0
29+
-D ADMIN_PASSWORD='"password"'
30+
; -D MESH_PACKET_LOGGING=1
31+
; -D MESH_DEBUG=1
32+
build_src_filter = ${T_Beam_S3_Supreme_SX1262.build_src_filter}
33+
+<../examples/simple_repeater>
34+
lib_deps =
35+
${T_Beam_S3_Supreme_SX1262.lib_deps}
36+
${esp32_ota.lib_deps}
37+
38+
[env:T_Beam_S3_Supreme_SX1262_room_server]
39+
extends = T_Beam_S3_Supreme_SX1262
40+
build_flags =
41+
${T_Beam_S3_Supreme_SX1262.build_flags}
42+
-D ADVERT_NAME='"T_Beam_S3_Supreme_SX1262 Room"'
43+
-D ADVERT_LAT=0.0
44+
-D ADVERT_LON=0.0
45+
-D ADMIN_PASSWORD='"password"'
46+
-D ROOM_PASSWORD='"hello"'
47+
; -D MESH_PACKET_LOGGING=1
48+
; -D MESH_DEBUG=1
49+
build_src_filter = ${T_Beam_S3_Supreme_SX1262.build_src_filter}
50+
+<../examples/simple_room_server>
51+
lib_deps =
52+
${T_Beam_S3_Supreme_SX1262.lib_deps}
53+
${esp32_ota.lib_deps}
54+
55+
[env:T_Beam_S3_Supreme_SX1262_companion_radio_ble]
56+
extends = T_Beam_S3_Supreme_SX1262
57+
build_flags =
58+
${T_Beam_S3_Supreme_SX1262.build_flags}
59+
-D MAX_CONTACTS=100
60+
-D MAX_GROUP_CHANNELS=1
61+
-D BLE_PIN_CODE=123456
62+
-D BLE_DEBUG_LOGGING=1
63+
; -D ENABLE_PRIVATE_KEY_IMPORT=1
64+
; -D ENABLE_PRIVATE_KEY_EXPORT=1
65+
-D MESH_PACKET_LOGGING=8
66+
-D MESH_DEBUG=1
67+
build_src_filter = ${T_Beam_S3_Supreme_SX1262.build_src_filter}
68+
+<helpers/esp32/*.cpp>
69+
+<../examples/companion_radio>
70+
lib_deps =
71+
${T_Beam_S3_Supreme_SX1262.lib_deps}
72+
densaugeo/base64 @ ~1.4.0

0 commit comments

Comments
 (0)