From 5ab34d5a98adcb99e767df4883aa08d0bf11420b Mon Sep 17 00:00:00 2001 From: Andy Shinn Date: Tue, 16 Sep 2025 23:07:22 -0500 Subject: [PATCH 1/7] adding the RAK13300 / RAK11200 ESP32 variant pair --- boards/wiscore_rak11200.json | 39 ++++++++ variants/rak11200/RAK11200Board.cpp | 36 +++++++ variants/rak11200/RAK11200Board.h | 25 +++++ variants/rak11200/pins_arduino.h | 50 ++++++++++ variants/rak11200/platformio.ini | 144 ++++++++++++++++++++++++++++ variants/rak11200/target.cpp | 63 ++++++++++++ variants/rak11200/target.h | 27 ++++++ variants/rak11200/variant.h | 63 ++++++++++++ 8 files changed, 447 insertions(+) create mode 100644 boards/wiscore_rak11200.json create mode 100644 variants/rak11200/RAK11200Board.cpp create mode 100644 variants/rak11200/RAK11200Board.h create mode 100644 variants/rak11200/pins_arduino.h create mode 100644 variants/rak11200/platformio.ini create mode 100644 variants/rak11200/target.cpp create mode 100644 variants/rak11200/target.h create mode 100644 variants/rak11200/variant.h diff --git a/boards/wiscore_rak11200.json b/boards/wiscore_rak11200.json new file mode 100644 index 0000000000..6d794b14ab --- /dev/null +++ b/boards/wiscore_rak11200.json @@ -0,0 +1,39 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": "-DARDUINO_ESP32_DEV", + "f_cpu": "240000000L", + "f_flash": "40000000L", + "flash_mode": "dio", + "mcu": "esp32", + "variant": "WisCore_RAK11200_Board" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "frameworks": [ + "arduino", + "espidf" + ], + "name": "WisCore RAK11200 Board", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "protocols": [ + "esptool", + "espota", + "ftdi" + ], + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://www.rakwireless.com", + "vendor": "RAKwireless" +} diff --git a/variants/rak11200/RAK11200Board.cpp b/variants/rak11200/RAK11200Board.cpp new file mode 100644 index 0000000000..ef07ce92c9 --- /dev/null +++ b/variants/rak11200/RAK11200Board.cpp @@ -0,0 +1,36 @@ +#include "RAK11200Board.h" + +void RAK11200Board::begin() { + ESP32Board::begin(); + + pinMode(PIN_VBAT_READ, INPUT); + + pinMode(SX126X_POWER_EN, OUTPUT); + digitalWrite(SX126X_POWER_EN, HIGH); + delay(10); // give sx1262 some time to power up + +#ifdef PIN_USER_BTN + pinMode(PIN_USER_BTN, INPUT_PULLUP); +#endif + +#ifdef PIN_USER_BTN_ANA + pinMode(PIN_USER_BTN_ANA, INPUT_PULLUP); +#endif +} + +uint16_t RAK11200Board::getBattMilliVolts() { + analogReadResolution(12); + + uint32_t raw = 0; + const int BATTERY_SAMPLES = 8; + for (int i = 0; i < BATTERY_SAMPLES; i++) { + raw += analogRead(PIN_VBAT_READ); + } + raw = raw / BATTERY_SAMPLES; + + return (ADC_MULTIPLIER * raw * 1000) / 4096; +} + +const char* RAK11200Board::getManufacturerName() const { + return "RAK 11200"; +} diff --git a/variants/rak11200/RAK11200Board.h b/variants/rak11200/RAK11200Board.h new file mode 100644 index 0000000000..67d74e6a05 --- /dev/null +++ b/variants/rak11200/RAK11200Board.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +// LoRa radio module pins when paired with the RAK13300 SX1262 module +#define P_LORA_DIO_1 22 // GPIO22 (ESP32 pin 36 -> IO6/DIO1) +#define P_LORA_NSS 32 // GPIO32 (ESP32 pin 8 -> SPI_CS) +#define P_LORA_RESET 23 // GPIO23 (ESP32 pin 37 -> IO4/NRESET) +#define P_LORA_BUSY RADIOLIB_NC +#define P_LORA_SCLK 33 // GPIO33 (ESP32 pin 9 -> SPI_SCK) +#define P_LORA_MISO 35 // GPIO35 (ESP32 pin 7 -> SPI_MISO) +#define P_LORA_MOSI 25 // GPIO25 (ESP32 pin 10 -> SPI_MOSI) +#define SX126X_POWER_EN 27 // GPIO27 (ESP32 pin 12 -> IO2) +#define PIN_VBAT_READ 36 // WB_A0 for battery reading +#define ADC_MULTIPLIER 1.8 // Adjusted for ESP32 ADC and voltage divider + +class RAK11200Board : public ESP32Board { + +public: + void begin(); + uint16_t getBattMilliVolts() override; + const char* getManufacturerName() const override; + +}; diff --git a/variants/rak11200/pins_arduino.h b/variants/rak11200/pins_arduino.h new file mode 100644 index 0000000000..7d609d91b0 --- /dev/null +++ b/variants/rak11200/pins_arduino.h @@ -0,0 +1,50 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#ifndef _VARIANT_RAK11200_ +#define _VARIANT_RAK11200_ +#endif + +#include + +#define EXTERNAL_NUM_INTERRUPTS 16 +#define NUM_DIGITAL_PINS 40 +#define NUM_ANALOG_INPUTS 16 + +#define analogInputToDigitalPin(p) (((p) < 20) ? (esp32_adc2gpio[(p)]) : -1) +#define digitalPinToInterrupt(p) (((p) < 40) ? (p) : -1) +#define digitalPinHasPWM(p) (p < 34) + +#define LED_GREEN 12 +#define LED_BLUE 2 + +#define LED_BUILTIN LED_GREEN + +static const uint8_t TX = 1; +static const uint8_t RX = 3; + +#define TX1 21 +#define RX1 19 + +#define WB_IO1 14 +#define WB_IO2 27 +#define WB_IO3 26 +#define WB_IO4 23 +#define WB_IO5 13 +#define WB_IO6 22 +#define WB_SW1 34 +#define WB_A0 36 +#define WB_A1 39 +#define WB_CS 32 +#define WB_LED1 12 +#define WB_LED2 2 + +static const uint8_t SDA = 4; +static const uint8_t SCL = 5; + +static const uint8_t SS = 32; +static const uint8_t MOSI = 25; +static const uint8_t MISO = 35; +static const uint8_t SCK = 33; + +#endif /* Pins_Arduino_h */ diff --git a/variants/rak11200/platformio.ini b/variants/rak11200/platformio.ini new file mode 100644 index 0000000000..3e2517380e --- /dev/null +++ b/variants/rak11200/platformio.ini @@ -0,0 +1,144 @@ +[rak11200] +extends = esp32_base +board = wiscore_rak11200 +board_build.partitions = min_spiffs.csv ; get around 4mb flash limit +build_unflags = -Os +build_type = release +build_flags = + ${esp32_base.build_flags} + ${sensor_base.build_flags} + -I variants/rak11200 + -D RAK_11200 + -D RAK_BOARD + -D PIN_BOARD_SCL=5 + -D PIN_BOARD_SDA=4 + -D PIN_GPS_TX=1 + -D PIN_GPS_RX=3 + -D PIN_GPS_EN=-1 + -D PIN_OLED_RESET=-1 + -D RADIO_CLASS=CustomSX1262 + -D WRAPPER_CLASS=CustomSX1262Wrapper + -D LORA_TX_POWER=22 + -D SX126X_CURRENT_LIMIT=140 + -D SX126X_DIO2_AS_RF_SWITCH=true + -D SX126X_DIO3_TCXO_VOLTAGE=1.8 + -D ENV_INCLUDE_GPS=0 + -D DISPLAY_CLASS=NullDisplayDriver +build_src_filter = ${esp32_base.build_src_filter} + +<../variants/rak11200> + + + + + + +lib_deps = + ${esp32_base.lib_deps} + ${sensor_base.lib_deps} + sparkfun/SparkFun u-blox GNSS Arduino Library@^2.2.27 + +[env:RAK_11200_Repeater] +extends = rak11200 +build_flags = + ${rak11200.build_flags} + -D ADVERT_NAME='"RAK11200 Repeater"' + -D ADVERT_LAT=0.0 + -D ADVERT_LON=0.0 + -D ADMIN_PASSWORD='"password"' + -D MAX_NEIGHBOURS=8 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${rak11200.build_src_filter} + +<../examples/simple_repeater> +lib_deps = + ${rak11200.lib_deps} + ${esp32_ota.lib_deps} + +[env:RAK_11200_room_server] +extends = rak11200 +build_flags = + ${rak11200.build_flags} + -D ADVERT_NAME='"Test Room"' + -D ADVERT_LAT=0.0 + -D ADVERT_LON=0.0 + -D ADMIN_PASSWORD='"password"' + -D ROOM_PASSWORD='"hello"' +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${rak11200.build_src_filter} + +<../examples/simple_room_server> +lib_deps = + ${rak11200.lib_deps} + ${esp32_ota.lib_deps} + +[env:RAK_11200_companion_radio_usb] +extends = rak11200 +build_flags = + ${rak11200.build_flags} + -I examples/companion_radio/ui-orig + -D PIN_USER_BTN=34 + -D PIN_USER_BTN_ANA=36 + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=8 +; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 +; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 +build_src_filter = ${rak11200.build_src_filter} + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-orig/*.cpp> +lib_deps = + ${rak11200.lib_deps} + ${esp32_ota.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:RAK_11200_companion_radio_ble] +extends = rak11200 +build_flags = + ${rak11200.build_flags} + -I examples/companion_radio/ui-orig + -D PIN_USER_BTN=34 + -D PIN_USER_BTN_ANA=36 + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=8 + -D BLE_PIN_CODE=123456 + -D BLE_DEBUG_LOGGING=1 + -D OFFLINE_QUEUE_SIZE=256 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${rak11200.build_src_filter} + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-orig/*.cpp> +lib_deps = + ${rak11200.lib_deps} + ${esp32_ota.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:RAK_11200_terminal_chat] +extends = rak11200 +build_flags = + ${rak11200.build_flags} + -D PIN_USER_BTN=34 + -D PIN_USER_BTN_ANA=36 + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=1 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${rak11200.build_src_filter} + +<../examples/simple_secure_chat/main.cpp> +lib_deps = + ${rak11200.lib_deps} + ${esp32_ota.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:RAK_11200_sensor] +extends = rak11200 +build_flags = + ${rak11200.build_flags} + -D ADVERT_NAME='"RAK11200 Sensor"' + -D ADVERT_LAT=0.0 + -D ADVERT_LON=0.0 + -D ADMIN_PASSWORD='"password"' +; -D MESH_PACKET_LOGGING=1 + -D MESH_DEBUG=1 +build_src_filter = ${rak11200.build_src_filter} + +<../examples/simple_sensor> +lib_deps = + ${rak11200.lib_deps} + ${esp32_ota.lib_deps} diff --git a/variants/rak11200/target.cpp b/variants/rak11200/target.cpp new file mode 100644 index 0000000000..ad4f1cc6af --- /dev/null +++ b/variants/rak11200/target.cpp @@ -0,0 +1,63 @@ +#include +#include "target.h" +#include + +RAK11200Board board; + +#ifndef PIN_USER_BTN + #define PIN_USER_BTN (-1) +#endif + +#ifdef DISPLAY_CLASS + DISPLAY_CLASS display; + MomentaryButton user_btn(PIN_USER_BTN, 1000, true, true); + + #if defined(PIN_USER_BTN_ANA) + MomentaryButton analog_btn(PIN_USER_BTN_ANA, 1000, 20); + #endif +#endif + +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); + +VolatileRTCClock fallback_clock; +AutoDiscoverRTCClock rtc_clock(fallback_clock); + +#if ENV_INCLUDE_GPS + #include + MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1); + EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea); +#else + EnvironmentSensorManager sensors; +#endif + +bool radio_init() { + rtc_clock.begin(Wire); + + #if defined(P_LORA_SCLK) + return radio.std_init(&SPI); + #else + return radio.std_init(); + #endif +} + +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); // create new random identity +} diff --git a/variants/rak11200/target.h b/variants/rak11200/target.h new file mode 100644 index 0000000000..dbc8bcfe91 --- /dev/null +++ b/variants/rak11200/target.h @@ -0,0 +1,27 @@ +#pragma once + +#define RADIOLIB_STATIC_ONLY 1 +#include +#include +#include +#include +#include +#include + +#ifdef DISPLAY_CLASS + #include + extern DISPLAY_CLASS display; + #include + extern MomentaryButton user_btn; +#endif + +extern RAK11200Board 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(); diff --git a/variants/rak11200/variant.h b/variants/rak11200/variant.h new file mode 100644 index 0000000000..e6b7c63cfe --- /dev/null +++ b/variants/rak11200/variant.h @@ -0,0 +1,63 @@ +#pragma once + +// RAK11200 WisBlock ESP32 Pin Definitions + +// I2C Interface (Main board I2C) +#define I2C_SDA 21 +#define I2C_SCL 22 + +// GPS Interface +#define GPS_TX_PIN 1 +#define GPS_RX_PIN 3 +#define PIN_GPS_EN -1 +#define GPS_POWER_TOGGLE +#define GPS_BAUD_RATE 9600 + +// User Interface +#define BUTTON_PIN 34 // WB_SW1 - User button +#define BATTERY_PIN 36 // WB_A0 - Battery voltage measurement pin +#define ADC_CHANNEL ADC1_GPIO36_CHANNEL +#define ADC_MULTIPLIER 1.85 // Adjust based on voltage divider +#define LED_PIN 12 // WB_LED1 - Status LED +#define LED_PIN_2 2 // WB_LED2 - Secondary LED + +// LoRa radio module pins for RAK11200 + RAK13300 SX1262 +#define P_LORA_DIO_1 22 // WB_IO6 - DIO1 interrupt pin +#define P_LORA_NSS 32 // WB_CS - SPI Chip Select +#define P_LORA_RESET 23 // WB_IO4 - Reset pin +#define P_LORA_BUSY RADIOLIB_NC // Not connected - using DIO2 for RF switching +#define P_LORA_SCLK 33 // SPI Clock +#define P_LORA_MISO 35 // SPI MISO +#define P_LORA_MOSI 25 // SPI MOSI + +// LoRa radio configuration +#define USE_SX1262 +#define SX126X_MAX_POWER 22 +#define SX126X_DIO2_AS_RF_SWITCH true +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 +#define SX126X_CURRENT_LIMIT 140 + +// Compatibility defines for variant file configuration structure +#define LORA_CS P_LORA_NSS +#define LORA_SCK P_LORA_SCLK +#define LORA_MOSI P_LORA_MOSI +#define LORA_MISO P_LORA_MISO +#define LORA_DIO1 P_LORA_DIO_1 + +// WisBlock GPIO mapping for RAK11200 +#define WB_IO1 14 // GPIO14 +#define WB_IO2 27 // GPIO27 +#define WB_IO3 26 // GPIO26 +#define WB_IO4 23 // GPIO23 +#define WB_IO5 13 // GPIO13 +#define WB_IO6 22 // GPIO22 +#define WB_SW1 34 // GPIO34 - Switch/Button +#define WB_A0 36 // GPIO36 - Analog input +#define WB_A1 39 // GPIO39 - Analog input +#define WB_CS 32 // GPIO32 - SPI Chip Select +#define WB_LED1 12 // GPIO12 - LED1 +#define WB_LED2 2 // GPIO2 - LED2 + +// Board identification +#define RAK_11200 +#define RAK_BOARD From 5afe5c231dfe466513335049e8d9f94e4a7a852a Mon Sep 17 00:00:00 2001 From: Andy Shinn Date: Tue, 23 Sep 2025 21:42:23 -0500 Subject: [PATCH 2/7] LORA_BUSY is actually connected, oops --- variants/rak11200/RAK11200Board.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/rak11200/RAK11200Board.h b/variants/rak11200/RAK11200Board.h index 67d74e6a05..8cf3c42f96 100644 --- a/variants/rak11200/RAK11200Board.h +++ b/variants/rak11200/RAK11200Board.h @@ -7,7 +7,7 @@ #define P_LORA_DIO_1 22 // GPIO22 (ESP32 pin 36 -> IO6/DIO1) #define P_LORA_NSS 32 // GPIO32 (ESP32 pin 8 -> SPI_CS) #define P_LORA_RESET 23 // GPIO23 (ESP32 pin 37 -> IO4/NRESET) -#define P_LORA_BUSY RADIOLIB_NC +#define P_LORA_BUSY 13 // GPIO13 (ESP32 pin 16 -> IO5) #define P_LORA_SCLK 33 // GPIO33 (ESP32 pin 9 -> SPI_SCK) #define P_LORA_MISO 35 // GPIO35 (ESP32 pin 7 -> SPI_MISO) #define P_LORA_MOSI 25 // GPIO25 (ESP32 pin 10 -> SPI_MOSI) From 096f601e57962f261dcff1508e614177fd24ce48 Mon Sep 17 00:00:00 2001 From: Andy Shinn Date: Tue, 23 Sep 2025 22:02:00 -0500 Subject: [PATCH 3/7] disable some sensors we don't use that have long timeouts on boot --- variants/rak11200/platformio.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/variants/rak11200/platformio.ini b/variants/rak11200/platformio.ini index 3e2517380e..b68a7d98bf 100644 --- a/variants/rak11200/platformio.ini +++ b/variants/rak11200/platformio.ini @@ -23,6 +23,9 @@ build_flags = -D SX126X_DIO2_AS_RF_SWITCH=true -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D ENV_INCLUDE_GPS=0 + -D RAK_WISBLOCK_GPS=0 + -D ENV_INCLUDE_INA3221=0 + -D ENV_INCLUDE_VL53L0X=0 ; Has a fairly long timeout of 40 seconds so we disable to prevent that startup delay -D DISPLAY_CLASS=NullDisplayDriver build_src_filter = ${esp32_base.build_src_filter} +<../variants/rak11200> From 6bbffc71a5418255a9357340935b6013036f72c9 Mon Sep 17 00:00:00 2001 From: Andy Shinn Date: Tue, 23 Sep 2025 22:39:29 -0500 Subject: [PATCH 4/7] better default multiplier for ESP32 RAK --- variants/rak11200/RAK11200Board.cpp | 2 +- variants/rak11200/RAK11200Board.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/variants/rak11200/RAK11200Board.cpp b/variants/rak11200/RAK11200Board.cpp index ef07ce92c9..602ce96cb5 100644 --- a/variants/rak11200/RAK11200Board.cpp +++ b/variants/rak11200/RAK11200Board.cpp @@ -28,7 +28,7 @@ uint16_t RAK11200Board::getBattMilliVolts() { } raw = raw / BATTERY_SAMPLES; - return (ADC_MULTIPLIER * raw * 1000) / 4096; + return (ADC_MULTIPLIER * raw) / 4096; } const char* RAK11200Board::getManufacturerName() const { diff --git a/variants/rak11200/RAK11200Board.h b/variants/rak11200/RAK11200Board.h index 8cf3c42f96..0c93d611c2 100644 --- a/variants/rak11200/RAK11200Board.h +++ b/variants/rak11200/RAK11200Board.h @@ -13,7 +13,7 @@ #define P_LORA_MOSI 25 // GPIO25 (ESP32 pin 10 -> SPI_MOSI) #define SX126X_POWER_EN 27 // GPIO27 (ESP32 pin 12 -> IO2) #define PIN_VBAT_READ 36 // WB_A0 for battery reading -#define ADC_MULTIPLIER 1.8 // Adjusted for ESP32 ADC and voltage divider +#define ADC_MULTIPLIER (3 * 1.73 * 1.110 * 1000) class RAK11200Board : public ESP32Board { From d9a555c5561cbc8361a6c6ab23057b98120220fd Mon Sep 17 00:00:00 2001 From: Wessel Nieboer Date: Thu, 5 Mar 2026 03:23:28 +0100 Subject: [PATCH 5/7] fix RAK11200 variant: pin corrections and convention alignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix I2C pins in variant.h (GPIO21/22 → GPIO4/5 per datasheet) - Fix GPS UART pins in platformio.ini (UART0 1/3 → UART1 21/19) - Fix radio_set_tx_power signature (uint8_t → int8_t) - Remove conflicting duplicate defines between variant.h and Board.h (P_LORA_BUSY was RADIOLIB_NC vs 13, ADC_MULTIPLIER was 1.85 vs 5761) - Remove stale LoRa/WisBlock defines from variant.h (Board.h is authoritative) - Remove "ethernet" and "can" from board JSON connectivity - Use static SPIClass for radio init (matches Heltec V3 convention) - Remove build_unflags=-Os (keep size optimization for 4MB flash) Verified against RAK11200/RAK13300 datasheets --- boards/wiscore_rak11200.json | 4 +-- variants/rak11200/platformio.ini | 6 ++-- variants/rak11200/target.cpp | 11 +++++-- variants/rak11200/target.h | 2 +- variants/rak11200/variant.h | 53 +++++--------------------------- 5 files changed, 20 insertions(+), 56 deletions(-) diff --git a/boards/wiscore_rak11200.json b/boards/wiscore_rak11200.json index 6d794b14ab..63f050f80a 100644 --- a/boards/wiscore_rak11200.json +++ b/boards/wiscore_rak11200.json @@ -13,9 +13,7 @@ }, "connectivity": [ "wifi", - "bluetooth", - "ethernet", - "can" + "bluetooth" ], "frameworks": [ "arduino", diff --git a/variants/rak11200/platformio.ini b/variants/rak11200/platformio.ini index b68a7d98bf..9f1d4a038b 100644 --- a/variants/rak11200/platformio.ini +++ b/variants/rak11200/platformio.ini @@ -2,8 +2,6 @@ extends = esp32_base board = wiscore_rak11200 board_build.partitions = min_spiffs.csv ; get around 4mb flash limit -build_unflags = -Os -build_type = release build_flags = ${esp32_base.build_flags} ${sensor_base.build_flags} @@ -12,8 +10,8 @@ build_flags = -D RAK_BOARD -D PIN_BOARD_SCL=5 -D PIN_BOARD_SDA=4 - -D PIN_GPS_TX=1 - -D PIN_GPS_RX=3 + -D PIN_GPS_TX=21 + -D PIN_GPS_RX=19 -D PIN_GPS_EN=-1 -D PIN_OLED_RESET=-1 -D RADIO_CLASS=CustomSX1262 diff --git a/variants/rak11200/target.cpp b/variants/rak11200/target.cpp index ad4f1cc6af..c3663d78a2 100644 --- a/variants/rak11200/target.cpp +++ b/variants/rak11200/target.cpp @@ -17,7 +17,12 @@ RAK11200Board board; #endif #endif -RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); +#if defined(P_LORA_SCLK) + static SPIClass spi; + RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi); +#else + RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY); +#endif WRAPPER_CLASS radio_driver(radio, board); @@ -36,7 +41,7 @@ bool radio_init() { rtc_clock.begin(Wire); #if defined(P_LORA_SCLK) - return radio.std_init(&SPI); + return radio.std_init(&spi); #else return radio.std_init(); #endif @@ -53,7 +58,7 @@ void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) { radio.setCodingRate(cr); } -void radio_set_tx_power(uint8_t dbm) { +void radio_set_tx_power(int8_t dbm) { radio.setOutputPower(dbm); } diff --git a/variants/rak11200/target.h b/variants/rak11200/target.h index dbc8bcfe91..4e3b952425 100644 --- a/variants/rak11200/target.h +++ b/variants/rak11200/target.h @@ -23,5 +23,5 @@ 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); +void radio_set_tx_power(int8_t dbm); mesh::LocalIdentity radio_new_identity(); diff --git a/variants/rak11200/variant.h b/variants/rak11200/variant.h index e6b7c63cfe..b7cdb303cc 100644 --- a/variants/rak11200/variant.h +++ b/variants/rak11200/variant.h @@ -1,63 +1,26 @@ #pragma once // RAK11200 WisBlock ESP32 Pin Definitions +// Reference: https://docs.rakwireless.com/Product-Categories/WisBlock/RAK11200/Datasheet/ +// Reference: https://docs.rakwireless.com/Product-Categories/WisBlock/RAK13300/Datasheet/ -// I2C Interface (Main board I2C) -#define I2C_SDA 21 -#define I2C_SCL 22 +// I2C Interface (I2C1 on WisBlock connector pins 19/20) +#define I2C_SDA 4 // GPIO4 +#define I2C_SCL 5 // GPIO5 -// GPS Interface -#define GPS_TX_PIN 1 -#define GPS_RX_PIN 3 +// GPS Interface (UART1) +#define GPS_TX_PIN 21 +#define GPS_RX_PIN 19 #define PIN_GPS_EN -1 -#define GPS_POWER_TOGGLE #define GPS_BAUD_RATE 9600 // User Interface #define BUTTON_PIN 34 // WB_SW1 - User button #define BATTERY_PIN 36 // WB_A0 - Battery voltage measurement pin #define ADC_CHANNEL ADC1_GPIO36_CHANNEL -#define ADC_MULTIPLIER 1.85 // Adjust based on voltage divider #define LED_PIN 12 // WB_LED1 - Status LED #define LED_PIN_2 2 // WB_LED2 - Secondary LED -// LoRa radio module pins for RAK11200 + RAK13300 SX1262 -#define P_LORA_DIO_1 22 // WB_IO6 - DIO1 interrupt pin -#define P_LORA_NSS 32 // WB_CS - SPI Chip Select -#define P_LORA_RESET 23 // WB_IO4 - Reset pin -#define P_LORA_BUSY RADIOLIB_NC // Not connected - using DIO2 for RF switching -#define P_LORA_SCLK 33 // SPI Clock -#define P_LORA_MISO 35 // SPI MISO -#define P_LORA_MOSI 25 // SPI MOSI - -// LoRa radio configuration -#define USE_SX1262 -#define SX126X_MAX_POWER 22 -#define SX126X_DIO2_AS_RF_SWITCH true -#define SX126X_DIO3_TCXO_VOLTAGE 1.8 -#define SX126X_CURRENT_LIMIT 140 - -// Compatibility defines for variant file configuration structure -#define LORA_CS P_LORA_NSS -#define LORA_SCK P_LORA_SCLK -#define LORA_MOSI P_LORA_MOSI -#define LORA_MISO P_LORA_MISO -#define LORA_DIO1 P_LORA_DIO_1 - -// WisBlock GPIO mapping for RAK11200 -#define WB_IO1 14 // GPIO14 -#define WB_IO2 27 // GPIO27 -#define WB_IO3 26 // GPIO26 -#define WB_IO4 23 // GPIO23 -#define WB_IO5 13 // GPIO13 -#define WB_IO6 22 // GPIO22 -#define WB_SW1 34 // GPIO34 - Switch/Button -#define WB_A0 36 // GPIO36 - Analog input -#define WB_A1 39 // GPIO39 - Analog input -#define WB_CS 32 // GPIO32 - SPI Chip Select -#define WB_LED1 12 // GPIO12 - LED1 -#define WB_LED2 2 // GPIO2 - LED2 - // Board identification #define RAK_11200 #define RAK_BOARD From 56957253fb4b16964c2ac96eb04f58a3c37a6250 Mon Sep 17 00:00:00 2001 From: Wessel Nieboer Date: Thu, 5 Mar 2026 03:34:38 +0100 Subject: [PATCH 6/7] remove adc override --- variants/rak11200/RAK11200Board.cpp | 13 ------------- variants/rak11200/RAK11200Board.h | 2 -- 2 files changed, 15 deletions(-) diff --git a/variants/rak11200/RAK11200Board.cpp b/variants/rak11200/RAK11200Board.cpp index 602ce96cb5..20b3a3c46a 100644 --- a/variants/rak11200/RAK11200Board.cpp +++ b/variants/rak11200/RAK11200Board.cpp @@ -18,19 +18,6 @@ void RAK11200Board::begin() { #endif } -uint16_t RAK11200Board::getBattMilliVolts() { - analogReadResolution(12); - - uint32_t raw = 0; - const int BATTERY_SAMPLES = 8; - for (int i = 0; i < BATTERY_SAMPLES; i++) { - raw += analogRead(PIN_VBAT_READ); - } - raw = raw / BATTERY_SAMPLES; - - return (ADC_MULTIPLIER * raw) / 4096; -} - const char* RAK11200Board::getManufacturerName() const { return "RAK 11200"; } diff --git a/variants/rak11200/RAK11200Board.h b/variants/rak11200/RAK11200Board.h index 0c93d611c2..ecd00fba92 100644 --- a/variants/rak11200/RAK11200Board.h +++ b/variants/rak11200/RAK11200Board.h @@ -13,13 +13,11 @@ #define P_LORA_MOSI 25 // GPIO25 (ESP32 pin 10 -> SPI_MOSI) #define SX126X_POWER_EN 27 // GPIO27 (ESP32 pin 12 -> IO2) #define PIN_VBAT_READ 36 // WB_A0 for battery reading -#define ADC_MULTIPLIER (3 * 1.73 * 1.110 * 1000) class RAK11200Board : public ESP32Board { public: void begin(); - uint16_t getBattMilliVolts() override; const char* getManufacturerName() const override; }; From 23f73902a6f9816b9dcfe6c4caffa97599172a8c Mon Sep 17 00:00:00 2001 From: Wessel Nieboer Date: Thu, 5 Mar 2026 04:06:05 +0100 Subject: [PATCH 7/7] Add wifi variant --- variants/rak11200/platformio.ini | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/variants/rak11200/platformio.ini b/variants/rak11200/platformio.ini index 9f1d4a038b..b362d6c611 100644 --- a/variants/rak11200/platformio.ini +++ b/variants/rak11200/platformio.ini @@ -111,6 +111,30 @@ lib_deps = ${esp32_ota.lib_deps} densaugeo/base64 @ ~1.4.0 +[env:RAK_11200_companion_radio_wifi] +extends = rak11200 +build_flags = + ${rak11200.build_flags} + -I examples/companion_radio/ui-orig + -D PIN_USER_BTN=34 + -D PIN_USER_BTN_ANA=36 + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=8 + -D WIFI_DEBUG_LOGGING=1 + -D WIFI_SSID='"myssid"' + -D WIFI_PWD='"mypwd"' + -D OFFLINE_QUEUE_SIZE=256 +; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 +; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 +build_src_filter = ${rak11200.build_src_filter} + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-orig/*.cpp> +lib_deps = + ${rak11200.lib_deps} + ${esp32_ota.lib_deps} + densaugeo/base64 @ ~1.4.0 + [env:RAK_11200_terminal_chat] extends = rak11200 build_flags =