Help Debugging RadioLib Init (-2 Error) on XIAO S3 + Wio-SX1262 (Meshtastic Works!) #6744
Replies: 4 comments 7 replies
-
Hi everyone, I'm at my wit's end trying to get a minimal RadioLib sketch to detect the SX1262 chip on a Seeed Studio XIAO ESP32-S3 connected via B2B connector to a Wio-SX1262 LoRa module. The baffling part is that Meshtastic firmware runs perfectly fine on this exact hardware, indicating the hardware itself (pins, module, antenna) is functional. However, every attempt to initialize RadioLib in a minimal sketch (using PlatformIO) consistently fails with Confirmed Hardware & Configuration (Based on Meshtastic Configs & Datasheets):
Extensive Troubleshooting Steps Taken (All Failed with Error -2):
The Core Problem & Question:Despite applying all known requirements (PWR_EN, correct pins, TCXO voltage, proper SPI initialization method for RadioLib), the SX1262 chip is never detected by Since Meshtastic does work, it must be doing something fundamentally different during its initialization phase that we are missing. This could be:
Could anyone familiar with the Meshtastic ( Any pointers or insights would be incredibly helpful! Last Failing Code (PlatformIO):
[env:seeed_xiao_esp32s3]
platform = espressif32@^6.10.0 ; Using a recent version
board = seeed_xiao_esp32s3
framework = arduino
monitor_speed = 115200
upload_protocol = esptool
lib_deps =
jgromes/RadioLib@^7.1.2 ; Tested also with 6.5.0
build_flags =
-D RADIO_TCXO_VOLTAGE=1.8
#include <Arduino.h>
#include <SPI.h>
#include <RadioLib.h>
// Pinout 1 (Forum - Confirmed via Meshtastic Config)
#define LORA_NSS_PIN 7
#define LORA_DIO1_PIN 1
#define LORA_RESET_PIN 4
#define LORA_BUSY_PIN 2
#define LORA_SCLK_PIN 36
#define LORA_MISO_PIN 37
#define LORA_MOSI_PIN 35
#define LORA_PWR_EN_PIN 5 // Power Enable Pin
// SPISettings (Tried 2MHz and 8MHz)
SPISettings sx1262SpiSettings(8000000, MSBFIRST, SPI_MODE0); // 8 MHz
// RadioLib Module Instanz (Correct Constructor)
SX1262 radio = new Module(LORA_NSS_PIN, LORA_DIO1_PIN, LORA_RESET_PIN, LORA_BUSY_PIN, SPI, sx1262SpiSettings);
// TCXO Spannung aus build_flags
#ifdef RADIO_TCXO_VOLTAGE
const float tcxoVoltage = RADIO_TCXO_VOLTAGE;
#else
#warning "RADIO_TCXO_VOLTAGE not defined, using 1.8V"
const float tcxoVoltage = 1.8;
#endif
void setup() {
Serial.begin(115200);
delay(2000);
Serial.println("\n=====================================");
Serial.println("PlatformIO RadioLib SX1262 Test - v13 (8MHz SPI, No TCXO in begin, MISO Pullup)");
Serial.println("=====================================");
// Schritt 1: Stromversorgung aktivieren
Serial.print("Activating LORA_PWR_EN_PIN (GPIO "); Serial.print(LORA_PWR_EN_PIN); Serial.println(")...");
pinMode(LORA_PWR_EN_PIN, OUTPUT);
digitalWrite(LORA_PWR_EN_PIN, HIGH);
delay(100);
Serial.println("Power Enable Done.");
// Schritt 2: Pin Modes setzen
Serial.println("Setting initial pin modes...");
pinMode(LORA_NSS_PIN, OUTPUT); digitalWrite(LORA_NSS_PIN, HIGH);
pinMode(LORA_RESET_PIN, OUTPUT); digitalWrite(LORA_RESET_PIN, HIGH);
pinMode(LORA_BUSY_PIN, INPUT);
pinMode(LORA_DIO1_PIN, INPUT);
pinMode(LORA_MISO_PIN, INPUT_PULLUP); // Tested with and without PULLUP
Serial.println("Pin modes set.");
// Schritt 3: Manueller Reset
Serial.println("Performing manual reset...");
digitalWrite(LORA_RESET_PIN, LOW); delay(100);
digitalWrite(LORA_RESET_PIN, HIGH); delay(500);
Serial.println("Manual reset done.");
// Schritt 4: SPI Init (Handled by RadioLib Constructor)
Serial.println("SPI initialization handled by RadioLib constructor with SPISettings(8MHz).");
delay(50);
// Schritt 5: Radio Initialisierung (Tried with and without tcxoVoltage param here)
Serial.print("Initializing SX1262 (Pinout 1), TCXO voltage "); Serial.print(tcxoVoltage); Serial.print("V assumed from build flags, using default regulator...");
int state = radio.begin(868.1, 125.0, 7, 5, RADIOLIB_SX126X_SYNC_WORD_PUBLIC, 14, 8); // Tried with tcxoVoltage param too
if (state == RADIOLIB_ERR_NONE) {
Serial.println("\n********** SUCCESS! Chip found! **********");
while(true) { delay(1000); }
} else {
Serial.print("FAILED! Chip not found or basic init failed, error code: "); Serial.println(state);
Serial.println("Last attempt failed. Hardware check (B2B) or deeper Meshtastic code analysis needed.");
while (true);
}
}
void loop() { } |
Beta Was this translation helpful? Give feedback.
-
Try using this example. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
#include <Arduino.h>
#include <SPI.h>
#include <RadioLib.h>
// Pinout 1 (Forum - Confirmed via Meshtastic Config)
#define I2C_SDA 5
#define I2C_SCL 6
#define LORA_NSS_PIN 41
#define LORA_DIO1_PIN 39
#define LORA_DIO2_PIN 38 //rf switch
#define LORA_RESET_PIN 42
#define LORA_BUSY_PIN 40
#define LORA_SCLK_PIN 7
#define LORA_MISO_PIN 8
#define LORA_MOSI_PIN 9
#define LORA_PWR_EN_PIN 5 // Power Enable Pin?!
#define LED_PIN 48
// SPISettings (Tried 2MHz and 8MHz)
// SPISettings sx1262SpiSettings(8000000, MSBFIRST, SPI_MODE0); // 8 MHz
// RadioLib Module Instanz (Correct Constructor)
// SX1262 radio = new Module(LORA_NSS_PIN, LORA_DIO1_PIN, LORA_RESET_PIN, LORA_BUSY_PIN, SPI, sx1262SpiSettings);
SX1262 radio = new Module(LORA_NSS_PIN, LORA_DIO1_PIN, LORA_RESET_PIN, LORA_BUSY_PIN);
// TCXO Spannung aus build_flags
#ifdef RADIO_TCXO_VOLTAGE
const float tcxoVoltage = RADIO_TCXO_VOLTAGE;
#else
#warning "RADIO_TCXO_VOLTAGE not defined, using 1.8V"
const float tcxoVoltage = 1.8;
#endif
void setup() {
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
Serial.begin(115200);
delay(3000);
digitalWrite(LED_PIN, LOW);
Serial.println("\n=====================================");
Serial.println("PlatformIO RadioLib SX1262 Test - v13 (8MHz SPI, No TCXO in begin, MISO Pullup)");
Serial.println("=====================================");
/*
// Schritt 1: Stromversorgung aktivieren Szetya:Die PIN-Konfiguration ist wahrscheinlich falsch.
Serial.print("Activating LORA_PWR_EN_PIN (GPIO "); Serial.print(LORA_PWR_EN_PIN); Serial.println(")...");
pinMode(LORA_PWR_EN_PIN, OUTPUT);
digitalWrite(LORA_PWR_EN_PIN, HIGH);
delay(100);
Serial.println("Power Enable Done.");
// Schritt 2: Pin Modes setzen Szetya: Das ist nicht notwendig, Radiolib wird die Aufgabe erfüllen.
Serial.println("Setting initial pin modes...");
pinMode(LORA_NSS_PIN, OUTPUT); digitalWrite(LORA_NSS_PIN, HIGH);
pinMode(LORA_RESET_PIN, OUTPUT); digitalWrite(LORA_RESET_PIN, HIGH);
pinMode(LORA_BUSY_PIN, INPUT);
pinMode(LORA_DIO1_PIN, INPUT);
pinMode(LORA_MISO_PIN, INPUT_PULLUP); // Tested with and without PULLUP
Serial.println("Pin modes set.");
*/
// Schritt 3: Manueller Reset Szetya: Das ist nicht notwendig, Radiolib wird die Aufgabe erfüllen.
Serial.println("Performing manual reset...");
digitalWrite(LORA_RESET_PIN, LOW); delay(100);
digitalWrite(LORA_RESET_PIN, HIGH); delay(500);
Serial.println("Manual reset done.");
// Schritt 4: SPI Init (Handled by RadioLib Constructor)
Serial.println("SPI initialization handled by RadioLib constructor with SPISettings(8MHz).");
delay(50);
// Schritt 5: Radio Initialisierung (Tried with and without tcxoVoltage param here)
Serial.print("Initializing SX1262 (Pinout 1), TCXO voltage "); Serial.print(tcxoVoltage); Serial.print("V assumed from build flags, using default regulator...");
int state = radio.begin(868.1f, 125.0f, 7, 5, RADIOLIB_SX126X_SYNC_WORD_PUBLIC, 14, 8, RADIO_TCXO_VOLTAGE); // Tried with tcxoVoltage param too
if (state == RADIOLIB_ERR_NONE) {
Serial.println("\n********** SUCCESS! Chip found! **********");
} else {
Serial.print("FAILED! Chip not found or basic init failed, error code: "); Serial.println(state);
Serial.println("Last attempt failed. Hardware check (B2B) or deeper Meshtastic code analysis needed.");
}
}
void loop() {
delay(1000);
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Meshtastic Community,
I'm facing a persistent issue trying to get a minimal RadioLib sketch working on a Seeed Studio XIAO ESP32-S3 connected to a Wio-SX1262 LoRa module via the B2B connector. The strange thing is that Meshtastic firmware runs perfectly fine on this exact hardware setup, sending and receiving packets.
However, when I try to run even the most basic RadioLib initialization sketch (just calling
radio.begin()
), it consistently fails witherror code -2 (RADIOLIB_ERR_CHIP_NOT_FOUND)
.Hardware & Confirmed Pinout:
platformio.ini
andpins_arduino.h
forseeed_xiao_esp32s3
):SCK
: GPIO36
MISO
: GPIO37
MOSI
: GPIO35
NSS
: GPIO7
RESET
: GPIO4
DIO1
: GPIO1
BUSY
: GPIO2
1.8V
(Confirmed via Meshtasticplatformio.ini
and Wio-SX1262 Datasheet)What I've Tried in Minimal Sketches:
(Using PlatformIO with latest stable ESP32 Core & RadioLib v7.1.2 / v6.5.0)
digitalWrite(RST, LOW); delay(50); digitalWrite(RST, HIGH); delay(200);
).1 MHz
).radio.begin()
variant that explicitly sets the TCXO voltage (1.8f
).radio.begin()
variants forcing LDO mode (just in case, though datasheet says DC-DC).radio.begin()
.v7.1.2
) and an older one (v6.5.0
).The core issue remains:
radio.begin()
fails with -2.Since Meshtastic works flawlessly, it strongly suggests there's some crucial pre-initialization step, specific GPIO configuration (pull-ups/downs?), power management setup, or a subtle RadioLib configuration detail that Meshtastic performs for the XIAO ESP32-S3 + Wio-SX1262 combo, which is missing in a standard minimal RadioLib example.
My Question:
Could anyone familiar with the Meshtastic codebase for the
seeed_xiao_esp32s3
variant shed some light on what specific initialization steps or configurations Meshtastic applies before or during the RadioLib initialization that might be critical for the SX1262 chip to be detected correctly on this hardware? Any pointers to the relevant sections in the Meshtastic source code (e.g., specific functions insrc/variants/
or elsewhere) would be greatly appreciated!Thanks in advance for any help!
Minimal Failing Example (PlatformIO
main.cpp
):Beta Was this translation helpful? Give feedback.
All reactions