From 8fa10a7813924facda3d0ea1d9891dbc82f88518 Mon Sep 17 00:00:00 2001 From: Ricardo Guzman Date: Wed, 23 Sep 2026 11:02:34 -0300 Subject: [PATCH] RAK3312 and 3112 added --- .github/workflows/build.yml | 4 +++ README.md | 2 +- src/battery_utils.cpp | 4 +++ src/lora_utils.cpp | 7 +++++ variants/RAK3112/board_pinout.h | 39 +++++++++++++++++++++++++ variants/RAK3112/platformio.ini | 15 ++++++++++ variants/RAK3312/board_pinout.h | 52 +++++++++++++++++++++++++++++++++ variants/RAK3312/platformio.ini | 15 ++++++++++ 8 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 variants/RAK3112/board_pinout.h create mode 100644 variants/RAK3112/platformio.ini create mode 100644 variants/RAK3312/board_pinout.h create mode 100644 variants/RAK3312/platformio.ini diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff9d94c..c25bf91 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -105,6 +105,10 @@ jobs: chip: esp32 - name: XIAO_ESP32S3_WIO_SX1262 chip: esp32s3 + - name: RAK3312 + chip: esp32s3 + - name: RAK3112 + chip: esp32s3 - name: TROY_LoRa_APRS chip: esp32 - name: ESP32_9M2IBR_1W_LoRa_GPS diff --git a/README.md b/README.md index da381dd..f293915 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ ____________________________________________________ - HELTEC V2, V3, V3.2, V4, T114, Wireless Stick, Wireless Stick Lite V3/V3.2, HT-CT62, Wireless Tracker, Wireless Paper. -- RAK Wireless 4631 + 19007(or 19003) +- RAK Wireless 4631 + 19007(or 19003), RAK3312 and RAK3112. - Faketec V3 (NRF52840 + Heltec HTRA62(SX1262)) diff --git a/src/battery_utils.cpp b/src/battery_utils.cpp index bb68144..6d05b5e 100644 --- a/src/battery_utils.cpp +++ b/src/battery_utils.cpp @@ -203,6 +203,10 @@ namespace BATTERY_Utils { #ifdef LIGHTGATEWAY_PLUS_1_0 double inputDivider = (1.0 / (560.0 + 100.0)) * 100.0; // The voltage divider is a 560k + 100k resistor in series, 100k on the low side. return (((sampleSum/adcReadings) * adcReadingTransformation) / inputDivider) + 0.41; + #elif defined(RAK3112) + return (sampleSum/adcReadings) * adcReadingTransformation * (3 * 1.73 * 1.187 / 3.3); // multiplier from MeshCore RAK3112Board.h + #elif defined(RAK3312) + return (sampleSum/adcReadings) * adcReadingTransformation * (3 * 1.73 * 1.187 / 3.3) * (1.667 / 2.11); // RAK3112 value scaled by Meshtastic RAK3312/RAK3112 ratio #else return (2 * (sampleSum/adcReadings) * adcReadingTransformation) + voltageDividerCorrection; // raw voltage without mapping #endif diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index 9c2519b..dff92ac 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -91,6 +91,10 @@ namespace LoRa_Utils { #else SPI.begin(RADIO_SCLK_PIN, RADIO_MISO_PIN, RADIO_MOSI_PIN); #endif + #ifdef RADIO_ANT_SW_PIN // RAK3312 antenna switch needs power + pinMode(RADIO_ANT_SW_PIN, OUTPUT); + digitalWrite(RADIO_ANT_SW_PIN, RADIO_ANT_SW_ON_STATE); + #endif float freq = (float)Config.loramodule.rxFreq / 1000000; #if defined(RADIO_HAS_XTAL) radio.XTAL = true; @@ -329,6 +333,9 @@ namespace LoRa_Utils { void sleepRadio() { radio.sleep(); + #ifdef RADIO_ANT_SW_PIN + digitalWrite(RADIO_ANT_SW_PIN, !RADIO_ANT_SW_ON_STATE); + #endif } } \ No newline at end of file diff --git a/variants/RAK3112/board_pinout.h b/variants/RAK3112/board_pinout.h new file mode 100644 index 0000000..d7fe00e --- /dev/null +++ b/variants/RAK3112/board_pinout.h @@ -0,0 +1,39 @@ +/* Copyright (C) 2025 Ricardo Guzman - CA2RXU + * + * This file is part of LoRa APRS iGate. + * + * LoRa APRS iGate is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * LoRa APRS iGate is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with LoRa APRS iGate. If not, see . + */ + +#ifndef BOARD_PINOUT_H_ +#define BOARD_PINOUT_H_ + + // LoRa Radio + #define HAS_SX1262 + #define HAS_TCXO + #define RADIO_SCLK_PIN 5 + #define RADIO_MISO_PIN 3 + #define RADIO_MOSI_PIN 6 + #define RADIO_CS_PIN 7 + #define RADIO_RST_PIN 8 + #define RADIO_DIO1_PIN 47 + #define RADIO_BUSY_PIN 48 + #define RADIO_WAKEUP_PIN RADIO_DIO1_PIN + #define GPIO_WAKEUP_PIN GPIO_SEL_47 + + // Aditional Config + #define INTERNAL_LED_PIN 46 + #define BATTERY_PIN 1 + +#endif diff --git a/variants/RAK3112/platformio.ini b/variants/RAK3112/platformio.ini new file mode 100644 index 0000000..adfb21a --- /dev/null +++ b/variants/RAK3112/platformio.ini @@ -0,0 +1,15 @@ +[env:RAK3112] +board = esp32-s3-devkitc-1 +board_build.mcu = esp32s3 +board_build.arduino.memory_type = qio_opi +board_upload.flash_size = 16MB +build_flags = + ${common.build_flags} + ${common.usb_flags} + -D RADIOLIB_EXCLUDE_LR11X0=1 + -D RADIOLIB_EXCLUDE_SX127X=1 + -D RADIOLIB_EXCLUDE_SX128X=1 + -D BOARD_HAS_PSRAM + -D RAK3112 +lib_deps = + ${common.lib_deps} diff --git a/variants/RAK3312/board_pinout.h b/variants/RAK3312/board_pinout.h new file mode 100644 index 0000000..495a254 --- /dev/null +++ b/variants/RAK3312/board_pinout.h @@ -0,0 +1,52 @@ +/* Copyright (C) 2025 Ricardo Guzman - CA2RXU + * + * This file is part of LoRa APRS iGate. + * + * LoRa APRS iGate is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * LoRa APRS iGate is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with LoRa APRS iGate. If not, see . + */ + +#ifndef BOARD_PINOUT_H_ +#define BOARD_PINOUT_H_ + + // LoRa Radio + #define HAS_SX1262 + #define HAS_TCXO + #define RADIO_SCLK_PIN 5 + #define RADIO_MISO_PIN 3 + #define RADIO_MOSI_PIN 6 + #define RADIO_CS_PIN 7 + #define RADIO_RST_PIN 8 + #define RADIO_DIO1_PIN 47 + #define RADIO_BUSY_PIN 48 + #define RADIO_WAKEUP_PIN RADIO_DIO1_PIN + #define GPIO_WAKEUP_PIN GPIO_SEL_47 + + #define RADIO_ANT_SW_PIN 4 // ANT_SW - antenna switch power enable + #define RADIO_ANT_SW_ON_STATE HIGH + + // Base Board Power + #define VEXT_CTRL_PIN 14 // 3V3_EN - powers GPS on Base Board + #define VEXT_CTRL_ON_STATE HIGH + + // GPS + #define HAS_GPS + #define GPS_BAUDRATE 9600 + #define GPS_RX 43 + #define GPS_TX 44 + + // Aditional Config + #define INTERNAL_LED_PIN 46 + #define BATTERY_PIN 1 + +#endif diff --git a/variants/RAK3312/platformio.ini b/variants/RAK3312/platformio.ini new file mode 100644 index 0000000..f7b3309 --- /dev/null +++ b/variants/RAK3312/platformio.ini @@ -0,0 +1,15 @@ +[env:RAK3312] +board = esp32-s3-devkitc-1 +board_build.mcu = esp32s3 +board_build.arduino.memory_type = qio_opi +board_upload.flash_size = 16MB +build_flags = + ${common.build_flags} + ${common.usb_flags} + -D RADIOLIB_EXCLUDE_LR11X0=1 + -D RADIOLIB_EXCLUDE_SX127X=1 + -D RADIOLIB_EXCLUDE_SX128X=1 + -D BOARD_HAS_PSRAM + -D RAK3312 +lib_deps = + ${common.lib_deps}