Merge remote-tracking branch 'origin/dev' into gps_sencecap_solar_p1

This commit is contained in:
Marnick Hartgers
2026-02-04 09:50:40 +01:00
40 changed files with 1679 additions and 201 deletions

View File

@@ -34,7 +34,6 @@ void T114Board::initiateShutdown(uint8_t reason) {
void T114Board::begin() {
NRF52Board::begin();
NRF_POWER->DCDCEN = 1;
pinMode(PIN_VBAT_READ, INPUT);

View File

@@ -58,8 +58,8 @@
////////////////////////////////////////////////////////////////////////////////
// I2C pin definition
#define PIN_WIRE_SDA (16) // P0.16
#define PIN_WIRE_SCL (13) // P0.13
#define PIN_WIRE_SDA (26) // P0.26
#define PIN_WIRE_SCL (27) // P0.27
////////////////////////////////////////////////////////////////////////////////
// SPI pin definition

View File

@@ -0,0 +1,71 @@
#include "TBeam1WBoard.h"
void TBeam1WBoard::begin() {
ESP32Board::begin();
// Power on radio module (must be done before radio init)
pinMode(SX126X_POWER_EN, OUTPUT);
digitalWrite(SX126X_POWER_EN, HIGH);
radio_powered = true;
delay(10); // Allow radio to power up
// RF switch RXEN pin handled by RadioLib via setRfSwitchPins()
// Initialize LED
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
// Initialize fan control (on by default - 1W PA can overheat)
pinMode(FAN_CTRL_PIN, OUTPUT);
digitalWrite(FAN_CTRL_PIN, HIGH);
}
void TBeam1WBoard::onBeforeTransmit() {
// RF switching handled by RadioLib via SX126X_DIO2_AS_RF_SWITCH and setRfSwitchPins()
digitalWrite(LED_PIN, HIGH); // TX LED on
}
void TBeam1WBoard::onAfterTransmit() {
digitalWrite(LED_PIN, LOW); // TX LED off
}
uint16_t TBeam1WBoard::getBattMilliVolts() {
// T-Beam 1W uses 7.4V battery with voltage divider
// ADC reads through divider - adjust multiplier based on actual divider ratio
analogReadResolution(12);
uint32_t raw = 0;
for (int i = 0; i < 8; i++) {
raw += analogRead(BATTERY_PIN);
}
raw = raw / 8;
// Assuming voltage divider ratio from ADC_MULTIPLIER
// 3.3V reference, 12-bit ADC (4095 max)
return static_cast<uint16_t>((raw * 3300 * ADC_MULTIPLIER) / 4095);
}
const char* TBeam1WBoard::getManufacturerName() const {
return "LilyGo T-Beam 1W";
}
void TBeam1WBoard::powerOff() {
// Turn off radio LNA (CTRL pin must be LOW when not receiving)
digitalWrite(SX126X_RXEN, LOW);
// Turn off radio power
digitalWrite(SX126X_POWER_EN, LOW);
radio_powered = false;
// Turn off LED and fan
digitalWrite(LED_PIN, LOW);
digitalWrite(FAN_CTRL_PIN, LOW);
ESP32Board::powerOff();
}
void TBeam1WBoard::setFanEnabled(bool enabled) {
digitalWrite(FAN_CTRL_PIN, enabled ? HIGH : LOW);
}
bool TBeam1WBoard::isFanEnabled() const {
return digitalRead(FAN_CTRL_PIN) == HIGH;
}

View File

@@ -0,0 +1,45 @@
#pragma once
#include <Arduino.h>
#include <helpers/ESP32Board.h>
#include "variant.h"
// LilyGo T-Beam 1W with SX1262 + external PA (XY16P35 module)
//
// Power architecture (LDO is separate chip on T-Beam board, not inside XY16P35):
//
// VCC (+4.0~+8.0V) ──┬──────────────────► XY16P35 VCC pin 5 (PA direct)
// (USB or Battery) │
// │ ┌───────────┐
// └──►│ LDO Chip │──► +3.3V ──► XY16P35 (SX1262 + LNA)
// │ EN=GPIO40 │
// └───────────┘
// LDO_EN (GPIO 40): H @ +1.2V~VIN, active high, not floating
//
// Control signals:
// - LDO_EN (GPIO 40): HIGH enables LDO → powers SX1262 + LNA
// - TCXO_EN (DIO3): HIGH enables TCXO (set to 1.8V per Meshtastic)
// - CTL (GPIO 21): HIGH=RX (LNA on), LOW=TX (LNA off)
// - DIO2: AUTO via SX126X_DIO2_AS_RF_SWITCH (TX path)
//
// Power notes:
// - PA needs VCC 4.0-8.0V for full 32dBm output
// - USB-C (3.9-6V) marginal; 7.4V battery recommended
// - Battery must support 2A+ discharge for high-power TX
class TBeam1WBoard : public ESP32Board {
private:
bool radio_powered = false;
public:
void begin();
void onBeforeTransmit() override;
void onAfterTransmit() override;
uint16_t getBattMilliVolts() override;
const char* getManufacturerName() const override;
void powerOff() override;
// Fan control methods
void setFanEnabled(bool enabled);
bool isFanEnabled() const;
};

View File

@@ -0,0 +1,26 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#include <stdint.h>
#define USB_VID 0x303a
#define USB_PID 0x1001
// Serial (USB CDC)
static const uint8_t TX = 43;
static const uint8_t RX = 44;
// I2C for OLED and sensors
static const uint8_t SDA = 8;
static const uint8_t SCL = 9;
// Default SPI mapped to Radio/SD
static const uint8_t SS = 15; // LoRa CS
static const uint8_t MOSI = 11;
static const uint8_t MISO = 12;
static const uint8_t SCK = 13;
// SD Card CS
#define SDCARD_CS 10
#endif /* Pins_Arduino_h */

View File

@@ -0,0 +1,193 @@
[LilyGo_TBeam_1W]
extends = esp32_base
board = t_beam_1w
build_flags =
${esp32_base.build_flags}
-I variants/lilygo_tbeam_1w
-D TBEAM_1W
; Radio - SX1262 with high-power PA (32dBm max output)
; Note: Set SX1262 output to 22dBm max, external PA provides additional gain
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D P_LORA_DIO_1=1
-D P_LORA_NSS=15
-D P_LORA_RESET=3
-D P_LORA_BUSY=38
-D P_LORA_SCLK=13
-D P_LORA_MISO=12
-D P_LORA_MOSI=11
; RF switch configuration:
; DIO2 controls TX path (PA enable) via SX126X_DIO2_AS_RF_SWITCH
; GPIO21 controls RX path (LNA enable) via SX126X_RXEN
; Truth table: DIO2=1,RXEN=0 → TX | DIO2=0,RXEN=1 → RX
-D SX126X_DIO2_AS_RF_SWITCH=true
-D SX126X_RXEN=21
-D SX126X_DIO3_TCXO_VOLTAGE=3.0
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
; TX power: 22dBm to SX1262, PA module adds ~10dB for 32dBm total
-D LORA_TX_POWER=22
; Battery - 2S 7.4V LiPo (6.0V min, 8.4V max)
-D BATT_MIN_MILLIVOLTS=6000
-D BATT_MAX_MILLIVOLTS=8400
; Display - SH1106 OLED at 0x3C
-D DISPLAY_CLASS=SH1106Display
; I2C pins
-D PIN_BOARD_SDA=8
-D PIN_BOARD_SCL=9
; GPS - L76K module
; GNSS_TXD (IO5) = GPS transmits → MCU RX
; GNSS_RXD (IO6) = GPS receives → MCU TX
-D PIN_GPS_TX=5
-D PIN_GPS_RX=6
-D PIN_GPS_EN=16
-D ENV_INCLUDE_GPS=1
; User interface
-D PIN_USER_BTN=17
build_src_filter = ${esp32_base.build_src_filter}
+<../variants/lilygo_tbeam_1w>
+<helpers/ui/SH1106Display.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<helpers/sensors>
lib_deps =
${esp32_base.lib_deps}
adafruit/Adafruit SH110X @ ~2.1.13
stevemarple/MicroNMEA @ ~2.0.6
; === LILYGO T-Beam 1W Repeater ===
[env:LilyGo_TBeam_1W_repeater]
extends = LilyGo_TBeam_1W
build_flags =
${LilyGo_TBeam_1W.build_flags}
-D ADVERT_NAME='"T-Beam 1W Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
-D PERSISTANT_GPS=1
-D ENV_SKIP_GPS_DETECT=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
+<../examples/simple_repeater>
lib_deps =
${LilyGo_TBeam_1W.lib_deps}
${esp32_ota.lib_deps}
; === LILYGO T-Beam 1W Room Server ===
[env:LilyGo_TBeam_1W_room_server]
extends = LilyGo_TBeam_1W
build_flags =
${LilyGo_TBeam_1W.build_flags}
-D ADVERT_NAME='"T-Beam 1W Room"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ROOM_PASSWORD='"hello"'
-D PERSISTANT_GPS=1
-D ENV_SKIP_GPS_DETECT=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
+<../examples/simple_room_server>
lib_deps =
${LilyGo_TBeam_1W.lib_deps}
${esp32_ota.lib_deps}
; === LILYGO T-Beam 1W Companion Radio (USB) ===
[env:LilyGo_TBeam_1W_companion_radio_usb]
extends = LilyGo_TBeam_1W
build_flags =
${LilyGo_TBeam_1W.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D PERSISTANT_GPS=1
-D ENV_SKIP_GPS_DETECT=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${LilyGo_TBeam_1W.lib_deps}
densaugeo/base64 @ ~1.4.0
; === LILYGO T-Beam 1W Companion Radio (BLE) ===
[env:LilyGo_TBeam_1W_companion_radio_ble]
extends = LilyGo_TBeam_1W
build_flags =
${LilyGo_TBeam_1W.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
-D OFFLINE_QUEUE_SIZE=256
-D PERSISTANT_GPS=1
-D ENV_SKIP_GPS_DETECT=1
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${LilyGo_TBeam_1W.lib_deps}
densaugeo/base64 @ ~1.4.0
; === LILYGO T-Beam 1W Companion Radio (WiFi) ===
[env:LilyGo_TBeam_1W_companion_radio_wifi]
extends = LilyGo_TBeam_1W
build_flags =
${LilyGo_TBeam_1W.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D WIFI_DEBUG_LOGGING=1
-D WIFI_SSID='"myssid"'
-D WIFI_PWD='"mypwd"'
-D PERSISTANT_GPS=1
-D ENV_SKIP_GPS_DETECT=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
+<helpers/esp32/*.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${LilyGo_TBeam_1W.lib_deps}
densaugeo/base64 @ ~1.4.0
; === LILYGO T-Beam 1W Repeater with ESPNow Bridge ===
[env:LilyGo_TBeam_1W_repeater_bridge_espnow]
extends = LilyGo_TBeam_1W
build_flags =
${LilyGo_TBeam_1W.build_flags}
-D ADVERT_NAME='"T-Beam 1W ESPNow Bridge"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
-D WITH_ESPNOW_BRIDGE=1
-D PERSISTANT_GPS=1
-D ENV_SKIP_GPS_DETECT=1
; -D BRIDGE_DEBUG=1
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter = ${LilyGo_TBeam_1W.build_src_filter}
+<helpers/bridges/ESPNowBridge.cpp>
+<../examples/simple_repeater>
lib_deps =
${LilyGo_TBeam_1W.lib_deps}
${esp32_ota.lib_deps}

View File

@@ -0,0 +1,64 @@
#include <Arduino.h>
#include "target.h"
TBeam1WBoard board;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
#endif
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
WRAPPER_CLASS radio_driver(radio, board);
ESP32RTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#if ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors;
#endif
bool radio_init() {
fallback_clock.begin();
rtc_clock.begin(Wire);
// Initialize SPI for radio
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
// GPS serial initialized by EnvironmentSensorManager::begin()
bool success = radio.std_init(&spi);
if (success) {
// T-Beam 1W has external PA requiring longer ramp time (>800us recommended)
// RADIOLIB_SX126X_PA_RAMP_800U = 0x05
radio.setTxParams(LORA_TX_POWER, RADIOLIB_SX126X_PA_RAMP_800U);
}
return success;
}
uint32_t radio_get_rng_seed() {
return radio.random(0x7FFFFFFF);
}
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
radio.setFrequency(freq);
radio.setSpreadingFactor(sf);
radio.setBandwidth(bw);
radio.setCodingRate(cr);
}
void radio_set_tx_power(uint8_t dbm) {
radio.setOutputPower(dbm);
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng);
}

View File

@@ -0,0 +1,27 @@
#pragma once
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/radiolib/CustomSX1262Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
#include "TBeam1WBoard.h"
#ifdef DISPLAY_CLASS
#include <helpers/ui/SH1106Display.h>
#include <helpers/ui/MomentaryButton.h>
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
#endif
extern TBeam1WBoard board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern EnvironmentSensorManager sensors;
bool radio_init();
uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(uint8_t dbm);
mesh::LocalIdentity radio_new_identity();

View File

@@ -0,0 +1,96 @@
// LilyGo T-Beam-1W variant.h
// Configuration based on Meshtastic PR #8967 and LilyGO documentation
#pragma once
// I2C for OLED display (SH1106 at 0x3C)
#define I2C_SDA 8
#define I2C_SCL 9
// GPS - Quectel L76K
// GNSS_TXD (IO5) = GPS transmits → MCU RX (setPins rxPin)
// GNSS_RXD (IO6) = GPS receives → MCU TX (setPins txPin)
#define PIN_GPS_TX 5 // MCU receives from GPS TX
#define PIN_GPS_RX 6 // MCU transmits to GPS RX
#define PIN_GPS_PPS 7 // GPS PPS output
#define PIN_GPS_EN 16 // GPS wake-up/enable (GPS_EN_PIN in LilyGO code)
#define HAS_GPS 1
#define GPS_BAUDRATE 9600
// Buttons
#define BUTTON_PIN 0 // BUTTON 1 (boot)
#define BUTTON_PIN_ALT 17 // BUTTON 2
// SPI (shared by LoRa and SD)
#define SPI_MOSI 11
#define SPI_SCK 13
#define SPI_MISO 12
#define SPI_CS 10
// SD Card
#define HAS_SDCARD
#define SDCARD_USE_SPI1
#define SDCARD_CS SPI_CS
// LoRa Radio - SX1262 with 1W PA
#define USE_SX1262
#define LORA_SCK SPI_SCK
#define LORA_MISO SPI_MISO
#define LORA_MOSI SPI_MOSI
#define LORA_CS 15
#define LORA_RESET 3
#define LORA_DIO1 1
#define LORA_BUSY 38
// CRITICAL: Radio power enable - MUST be HIGH before lora.begin()!
// GPIO 40 powers the SX1262 + PA module via LDO
#define SX126X_POWER_EN 40
#ifdef USE_SX1262
#define SX126X_CS LORA_CS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_BUSY
#define SX126X_RESET LORA_RESET
// RF switching configuration for 1W PA module
// DIO2 controls PA (via SX126X_DIO2_AS_RF_SWITCH)
// CTRL PIN (GPIO 21) controls LNA - must be HIGH during RX
// Truth table: DIO2=1,CTRL=0 -> TX (PA on, LNA off)
// DIO2=0,CTRL=1 -> RX (PA off, LNA on)
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_RXEN 21 // LNA enable - HIGH during RX
// TCXO voltage - required for radio init
#define SX126X_DIO3_TCXO_VOLTAGE 3.0
#define SX126X_MAX_POWER 22
#endif
// LED
#define LED_PIN 18
#define LED_STATE_ON 1 // HIGH = ON
// Battery ADC
#define BATTERY_PIN 4
#define ADC_CHANNEL ADC1_GPIO4_CHANNEL
#define BATTERY_SENSE_SAMPLES 30
#define ADC_MULTIPLIER 3.0
// NTC temperature sensor
#define NTC_PIN 14
// Fan control
#define FAN_CTRL_PIN 41
// PA Ramp Time - T-Beam 1W requires >800us stabilization (default is 200us)
// Value 0x05 = RADIOLIB_SX126X_PA_RAMP_800U
#define SX126X_PA_RAMP_US 0x05
// Display - SH1106 OLED (128x64)
#define USE_SH1106
#define OLED_WIDTH 128
#define OLED_HEIGHT 64
// 32768 Hz crystal present
#define HAS_32768HZ 1

View File

@@ -4,30 +4,6 @@
#include <Arduino.h>
#include <helpers/NRF52Board.h>
// LoRa radio module pins for RAK13302
#define P_LORA_SCLK 3
#define P_LORA_MISO 29
#define P_LORA_MOSI 30
#define P_LORA_NSS 26
#define P_LORA_DIO_1 10
#define P_LORA_BUSY 9
#define P_LORA_RESET 4
#ifndef P_LORA_PA_EN
#define P_LORA_PA_EN 31
#endif
//#define PIN_GPS_SDA 13 //GPS SDA pin (output option)
//#define PIN_GPS_SCL 14 //GPS SCL pin (output option)
// #define PIN_GPS_TX 16 //GPS TX pin
// #define PIN_GPS_RX 15 //GPS RX pin
#define PIN_GPS_1PPS 17 //GPS PPS pin
#define GPS_BAUD_RATE 9600
#define GPS_ADDRESS 0x42 //i2c address for GPS
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
// built-ins
#define PIN_VBAT_READ 5
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
@@ -35,9 +11,13 @@
#define PIN_3V3_EN (34)
#define WB_IO2 PIN_3V3_EN
class RAK3401Board : public NRF52BoardDCDC, public NRF52BoardOTA {
class RAK3401Board : public NRF52BoardDCDC {
protected:
#ifdef NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
#endif
public:
RAK3401Board() : NRF52BoardOTA("RAK3401_OTA") {}
RAK3401Board() : NRF52Board("RAK3401_OTA") {}
void begin();
#define BATTERY_SAMPLES 8

View File

@@ -141,11 +141,6 @@ static const uint8_t AREF = PIN_AREF;
#define EXTERNAL_FLASH_DEVICES IS25LP080D
#define EXTERNAL_FLASH_USE_QSPI
#define P_LORA_SCK PIN_SPI1_SCK
#define P_LORA_MISO PIN_SPI1_MISO
#define P_LORA_MOSI PIN_SPI1_MOSI
#define P_LORA_CS 26
#define USE_SX1262
#define SX126X_CS (26)
#define SX126X_DIO1 (10)
@@ -157,6 +152,15 @@ static const uint8_t AREF = PIN_AREF;
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
#define P_LORA_SCLK PIN_SPI1_SCK
#define P_LORA_MISO PIN_SPI1_MISO
#define P_LORA_MOSI PIN_SPI1_MOSI
#define P_LORA_NSS SX126X_CS
#define P_LORA_DIO_1 SX126X_DIO1
#define P_LORA_BUSY SX126X_BUSY
#define P_LORA_RESET SX126X_RESET
#define P_LORA_PA_EN 31
// enables 3.3V periphery like GPS or IO Module
// Do not toggle this for GPS power savings
#define PIN_3V3_EN (34)
@@ -173,6 +177,10 @@ static const uint8_t AREF = PIN_AREF;
#define PIN_GPS_RX PIN_SERIAL1_RX
#define PIN_GPS_TX PIN_SERIAL1_TX
#define PIN_GPS_1PPS PIN_GPS_PPS
#define GPS_BAUD_RATE 9600
#define GPS_ADDRESS 0x42 //i2c address for GPS
// Battery
// The battery sense is hooked to pin A0 (5)
#define BATTERY_PIN PIN_A0

View File

@@ -4,27 +4,6 @@
#include <Arduino.h>
#include <helpers/NRF52Board.h>
// LoRa radio module pins for RAK4631
#define P_LORA_DIO_1 47
#define P_LORA_NSS 42
#define P_LORA_RESET RADIOLIB_NC // 38
#define P_LORA_BUSY 46
#define P_LORA_SCLK 43
#define P_LORA_MISO 45
#define P_LORA_MOSI 44
#define SX126X_POWER_EN 37
//#define PIN_GPS_SDA 13 //GPS SDA pin (output option)
//#define PIN_GPS_SCL 14 //GPS SCL pin (output option)
//#define PIN_GPS_TX 16 //GPS TX pin
//#define PIN_GPS_RX 15 //GPS RX pin
#define PIN_GPS_1PPS 17 //GPS PPS pin
#define GPS_BAUD_RATE 9600
#define GPS_ADDRESS 0x42 //i2c address for GPS
#define SX126X_DIO2_AS_RF_SWITCH true
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
// built-ins
#define PIN_VBAT_READ 5
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)

View File

@@ -144,6 +144,19 @@ extern "C"
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK = PIN_SPI_SCK;
// LoRa radio module pins for RAK4631
#define P_LORA_DIO_1 (47)
#define P_LORA_NSS (42)
#define P_LORA_RESET (-1)
#define P_LORA_BUSY (46)
#define P_LORA_SCLK (43)
#define P_LORA_MISO (45)
#define P_LORA_MOSI (44)
#define SX126X_POWER_EN (37)
#define SX126X_DIO2_AS_RF_SWITCH true
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
/*
* Wire Interfaces
*/
@@ -155,19 +168,23 @@ extern "C"
#define PIN_WIRE1_SDA (24)
#define PIN_WIRE1_SCL (25)
// QSPI Pins
// QSPI occupied by GPIO's
#define PIN_QSPI_SCK 3 // 19
#define PIN_QSPI_CS 26 // 17
#define PIN_QSPI_IO0 30 // 20
#define PIN_QSPI_IO1 29 // 21
#define PIN_QSPI_IO2 28 // 22
#define PIN_QSPI_IO3 2 // 23
// QSPI Pins
// QSPI occupied by GPIO's
#define PIN_QSPI_SCK 3 // 19
#define PIN_QSPI_CS 26 // 17
#define PIN_QSPI_IO0 30 // 20
#define PIN_QSPI_IO1 29 // 21
#define PIN_QSPI_IO2 28 // 22
#define PIN_QSPI_IO3 2 // 23
// On-board QSPI Flash
// No onboard flash
#define EXTERNAL_FLASH_DEVICES IS25LP080D
#define EXTERNAL_FLASH_USE_QSPI
// On-board QSPI Flash
// No onboard flash
#define EXTERNAL_FLASH_DEVICES IS25LP080D
#define EXTERNAL_FLASH_USE_QSPI
#define PIN_GPS_1PPS 17 //GPS PPS pin
#define GPS_BAUD_RATE 9600
#define GPS_ADDRESS 0x42 //i2c address for GPS
#ifdef __cplusplus
}

View File

@@ -0,0 +1,28 @@
#include <Arduino.h>
#include "ThinkNodeM3Board.h"
#include <Wire.h>
#include <bluefruit.h>
void ThinkNodeM3Board::begin() {
NRF52Board::begin();
btn_prev_state = HIGH;
Wire.begin();
delay(10); // give sx1262 some time to power up
}
uint16_t ThinkNodeM3Board::getBattMilliVolts() {
int adcvalue = 0;
analogReference(AR_INTERNAL_2_4);
analogReadResolution(ADC_RESOLUTION);
delay(10);
// ADC range is 0..2400mV and resolution is 12-bit (0..4095)
adcvalue = analogRead(PIN_VBAT_READ);
// Convert the raw value to compensated mv, taking the resistor-
// divider into account (providing the actual LIPO voltage)
return (uint16_t)((float)adcvalue * ADC_FACTOR);
}

View File

@@ -0,0 +1,54 @@
#pragma once
#include <Arduino.h>
#include <MeshCore.h>
#include <helpers/NRF52Board.h>
#define ADC_FACTOR ((1000.0*ADC_MULTIPLIER*AREF_VOLTAGE)/ADC_MAX)
class ThinkNodeM3Board : public NRF52BoardDCDC {
protected:
#if NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
#endif
uint8_t btn_prev_state;
public:
ThinkNodeM3Board() : NRF52Board("THINKNODE_M3_OTA") {}
void begin();
uint16_t getBattMilliVolts() override;
#if defined(P_LORA_TX_LED)
void onBeforeTransmit() override {
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
}
void onAfterTransmit() override {
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
}
#endif
const char* getManufacturerName() const override {
return "Elecrow ThinkNode M3";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == LOW) ? 1 : -1;
}
#endif
return 0;
}
void powerOff() override {
// turn off all leds, sd_power_system_off will not do this for us
#ifdef P_LORA_TX_LED
digitalWrite(P_LORA_TX_LED, LOW);
#endif
// power off board
sd_power_system_off();
}
};

View File

@@ -1,14 +0,0 @@
#include <Arduino.h>
#include "ThinknodeM3Board.h"
#include <Wire.h>
#include <bluefruit.h>
void ThinknodeM3Board::begin() {
Nrf52BoardDCDC::begin();
btn_prev_state = HIGH;
Wire.begin();
delay(10); // give sx1262 some time to power up
}

View File

@@ -1,58 +0,0 @@
#pragma once
#include <Arduino.h>
#include <MeshCore.h>
#include <helpers/NRF52Board.h>
#define ADC_FACTOR ((1000.0*ADC_MULTIPLIER*AREF_VOLTAGE)/ADC_MAX)
class ThinknodeM3Board : public Nrf52BoardDCDC {
protected:
uint8_t btn_prev_state;
public:
void begin();
uint16_t getBattMilliVolts() override {
int adcvalue = 0;
analogReference(AR_INTERNAL_2_4);
analogReadResolution(ADC_RESOLUTION);
delay(10);
// ADC range is 0..2400mV and resolution is 12-bit (0..4095)
adcvalue = analogRead(PIN_VBAT_READ);
// Convert the raw value to compensated mv, taking the resistor-
// divider into account (providing the actual LIPO voltage)
return (uint16_t)((float)adcvalue * ADC_FACTOR);
}
#if defined(P_LORA_TX_LED)
#if !defined(P_LORA_TX_LED_ON)
#define P_LORA_TX_LED_ON HIGH
#endif
void onBeforeTransmit() override {
digitalWrite(P_LORA_TX_LED, P_LORA_TX_LED_ON); // turn TX LED on
}
void onAfterTransmit() override {
digitalWrite(P_LORA_TX_LED, !P_LORA_TX_LED_ON); // turn TX LED off
}
#endif
const char* getManufacturerName() const override {
return "Elecrow ThinkNode M3";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == LOW) ? 1 : -1;
}
#endif
return 0;
}
void powerOff() override { sd_power_system_off(); }
};

View File

@@ -2,7 +2,7 @@
#include "target.h"
#include <helpers/sensors/MicroNMEALocationProvider.h>
ThinknodeM3Board board;
ThinkNodeM3Board board;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
@@ -30,26 +30,26 @@ static const uint32_t rfswitch_dios[Module::RFSWITCH_MAX_PINS] = {
RADIOLIB_LR11X0_DIO5,
RADIOLIB_LR11X0_DIO6,
RADIOLIB_NC,
RADIOLIB_NC,
RADIOLIB_NC,
RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6
{ LR11x0::MODE_STBY, {LOW , LOW }},
// mode DIO5 DIO6
{ LR11x0::MODE_STBY, {LOW , LOW }},
{ LR11x0::MODE_RX, {HIGH, LOW }},
{ LR11x0::MODE_TX, {HIGH, HIGH }},
{ LR11x0::MODE_TX_HP, {LOW , HIGH }},
{ LR11x0::MODE_TX_HF, {LOW , LOW }},
{ LR11x0::MODE_TX_HF, {LOW , LOW }},
{ LR11x0::MODE_GNSS, {LOW , LOW }},
{ LR11x0::MODE_WIFI, {LOW , LOW }},
{ LR11x0::MODE_WIFI, {LOW , LOW }},
END_OF_MODE_TABLE,
};
#endif
bool radio_init() {
rtc_clock.begin(Wire);
#ifdef LR11X0_DIO3_TCXO_VOLTAGE
float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
#else
@@ -64,7 +64,7 @@ bool radio_init() {
Serial.println(status);
return false; // fail
}
radio.setCRC(2);
radio.explicitHeader();

View File

@@ -3,7 +3,7 @@
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include "ThinknodeM3Board.h"
#include "ThinkNodeM3Board.h"
#include <helpers/radiolib/CustomLR1110Wrapper.h>
#include <helpers/ArduinoHelpers.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
@@ -17,7 +17,7 @@
extern NullDisplayDriver display;
#endif
extern ThinknodeM3Board board;
extern ThinkNodeM3Board board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern EnvironmentSensorManager sensors;

View File

@@ -12,9 +12,14 @@
#define PIN_VBAT_READ BATTERY_PIN
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
class ThinkNodeM6Board : public Nrf52BoardOTA {
class ThinkNodeM6Board : public NRF52BoardDCDC {
protected:
#if NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
#endif
public:
ThinkNodeM6Board() : NRF52BoardOTA("THINKNODE_M1_OTA") {}
ThinkNodeM6Board() : NRF52Board("THINKNODE_M6_OTA") {}
void begin();
uint16_t getBattMilliVolts() override;
@@ -25,10 +30,10 @@ public:
void onAfterTransmit() override {
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
}
#endif
#endif
const char* getManufacturerName() const override {
return "Elecrow ThinkNode-M6";
return "Elecrow ThinkNode M6";
}
void powerOff() override {