-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raspberry Pico + SX 1262 #729
Comments
I don't have either the RP2040 or the waveshare module, but looking at the pinout diagram, I think you may have used the physical device pin numbers (1 - 40) as opposed to the actual GPIO pin number (GPxy). Can you try |
Thanks for the fast response! But i still get: |
In that case please fill in the "module not working" template, especially post the debug output. |
Sketch that is causing the module fail //SX126x_Transmit Example Code
// include the library
#include <RadioLib.h>
// SX1262 has the following connections:
// NSS pin: 10 3
// DIO1 pin: 2 20
// NRST pin: 3 15
// BUSY pin: 9 2
SX1262 radio = new Module(3, 20, 15, 2);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//SX1262 radio = RadioShield.ModuleA;
// or using CubeCell
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
void setup() {
Serial.begin(9600);
// initialize SX1262 with default settings
Serial.print(F("[SX1262] Initializing ... "));
int state = radio.begin();
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true);
}
// some modules have an external RF switch
// controlled via two pins (RX enable, TX enable)
// to enable automatic control of the switch,
// call the following method
// RX enable: 4
// TX enable: 5
/*
radio.setRfSwitchPins(4, 5);
*/
}
void loop() {
Serial.print(F("[SX1262] Transmitting packet ... "));
// you can transmit C-string or Arduino string up to
// 256 characters long
// NOTE: transmit() is a blocking method!
// See example SX126x_Transmit_Interrupt for details
// on non-blocking transmission method.
int state = radio.transmit("Hello World!");
// you can also transmit byte array up to 256 bytes long
/*
byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF};
int state = radio.transmit(byteArr, 8);
*/
if (state == RADIOLIB_ERR_NONE) {
// the packet was successfully transmitted
Serial.println(F("success!"));
// print measured data rate
Serial.print(F("[SX1262] Datarate:\t"));
Serial.print(radio.getDataRate());
Serial.println(F(" bps"));
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
// the supplied packet was longer than 256 bytes
Serial.println(F("too long!"));
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
// timeout occured while transmitting packet
Serial.println(F("timeout!"));
} else {
// some other error occurred
Serial.print(F("failed, code "));
Serial.println(state);
}
// wait for a second before transmitting again
delay(1000);
}
Hardware setup Debug mode output Additional info
|
Please provide the debug mode output as shown on this wiki page: https://github.com/jgromes/RadioLib/wiki/Debug-mode |
What do I have to add to the code to get the Debug informations via Serial? I already uncomment in the BuildOpt.h |
Did you upload the changed version into the RP2040? |
Yes. I uncomment in BuildOpt.h and upload the above example code to the RP2040. |
In that case it's looking like at least the BUSY pin is not connected. I suggest to double check the pin numbers listed on the manufacturer site actually correspond to RP2040 pins in Arduino IDE. |
I got the RP2040 with SX1262 Waveshare hat to initialize when using |
Thanks for your response. Sadly, that didnt work. Compilation error: 'SPI1' was not declared in this scope |
That's a limitation of ArduinoCore-mbed then, as it seems to only support one SPI interface: https://github.com/arduino/ArduinoCore-mbed/blob/main/variants/RASPBERRY_PI_PICO/pins_arduino.h#L72 I'm using https://github.com/maxgerhardt/platform-raspberrypi with PlatformIO. |
@Steffen54321 it seems like there was no updates to this, so I'm going to have to close this as inactive. Feel free to reopen later if more information becomes available. |
Hi, I face the same issue with the Waveshare SX1262 Shield (https://www.waveshare.com/pico-lora-sx1262-868m.htm). I'm using the shield with a Raspberry Pi Pico W. The last debug error messages are SX126x not found! (10 of 10 tries) RADIOLIB_SX126X_REG_VERSION_STRING: Debug output below. Using Thanks for your help. Sketch that is causing the module fail /*
RadioLib SX126x Transmit Example
This example transmits packets using SX1262 LoRa radio module.
Each packet contains up to 256 bytes of data, in the form of:
- Arduino String
- null-terminated char array (C-string)
- arbitrary binary data (byte array)
Other modules from SX126x family can also be used.
For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// SX1262 has the following connections:
// NSS pin: 10
// DIO1 pin: 2
// NRST pin: 3
// BUSY pin: 9
SX1262 radio = new Module(3, 20, 15, 2);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//SX1262 radio = RadioShield.ModuleA;
// or using CubeCell
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
void setup() {
Serial.begin(9600);
// initialize SX1262 with default settings
Serial.print(F("[SX1262] Initializing ... "));
int state = radio.begin();
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true);
}
// some modules have an external RF switch
// controlled via two pins (RX enable, TX enable)
// to enable automatic control of the switch,
// call the following method
// RX enable: 4
// TX enable: 5
/*
radio.setRfSwitchPins(4, 5);
*/
}
void loop() {
Serial.print(F("[SX1262] Transmitting packet ... "));
// you can transmit C-string or Arduino string up to
// 256 characters long
// NOTE: transmit() is a blocking method!
// See example SX126x_Transmit_Interrupt for details
// on non-blocking transmission method.
int state = radio.transmit("Hello World!");
// you can also transmit byte array up to 256 bytes long
/*
byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF};
int state = radio.transmit(byteArr, 8);
*/
if (state == RADIOLIB_ERR_NONE) {
// the packet was successfully transmitted
Serial.println(F("success!"));
// print measured data rate
Serial.print(F("[SX1262] Datarate:\t"));
Serial.print(radio.getDataRate());
Serial.println(F(" bps"));
} else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) {
// the supplied packet was longer than 256 bytes
Serial.println(F("too long!"));
} else if (state == RADIOLIB_ERR_TX_TIMEOUT) {
// timeout occured while transmitting packet
Serial.println(F("timeout!"));
} else {
// some other error occurred
Serial.print(F("failed, code "));
Serial.println(state);
}
// wait for a second before transmitting again
delay(1000);
}
Hardware setup Debug mode output CMD 80 CMD 80 CMD 80 CMD 80 CMD 80 CMD 80 CMD 80 CMD 1D 3 20 SX126x not found! (10 of 10 tries) RADIOLIB_SX126X_REG_VERSION_STRING: Additional info (please complete):
|
I also had to set the correct pins for
|
@MarkusLoew are you using the correct SPI bus? Since you didn't provide any to the |
Success! The code from @GUVWAF #729 (comment) regarding the non-standard SPI setup did the trick! Thank you very much for your quick help @GUVWAF and @jgromes , much appreciated!
[...]
[...] Later, I get error code -705, which is probably a different, unrelated issue.
The working sx1262_receive code I ended up with for completeness: #include <RadioLib.h>
/*
RadioLib SX126x Receive Example
This example listens for LoRa transmissions using SX126x Lora modules.
To successfully receive data, the following settings have to be the same
on both transmitter and receiver:
- carrier frequency
- bandwidth
- spreading factor
- coding rate
- sync word
- preamble length
Other modules from SX126x family can also be used.
For default module settings, see the wiki page
https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx126x---lora-modem
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// SX1262 has the following connections:
// NSS pin: 10
// DIO1 pin: 2
// NRST pin: 3
// BUSY pin: 9
SX1262 radio = new Module(3, 20, 15, 2, SPI1, RADIOLIB_DEFAULT_SPI_SETTINGS);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//SX1262 radio = RadioShield.ModuleA;
// or using CubeCell
//SX1262 radio = new Module(RADIOLIB_BUILTIN_MODULE);
void setup() {
SPI1.setSCK(10);
SPI1.setTX(11);
SPI1.setRX(12);
pinMode(3, OUTPUT);
digitalWrite(3, HIGH);
SPI1.begin(false);
Serial.begin(9600);
// "Initializing" and "Found" messages not showing without waiting for serial connection
while (!Serial)
{
; // Wait for serial to connect
}
Serial.println("Start");
// initialize SX1262 with default settings
Serial.print(F("[SX1262] Initializing ... "));
int state = radio.begin();
if (state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while (true)
;
}
}
void loop() {
Serial.print(F("[SX1262] Waiting for incoming transmission ... "));
// you can receive data as an Arduino String
// NOTE: receive() is a blocking method!
// See example ReceiveInterrupt for details
// on non-blocking reception method.
String str;
int state = radio.receive(str);
// you can also receive data as byte array
/*
byte byteArr[8];
int state = radio.receive(byteArr, 8);
*/
if (state == RADIOLIB_ERR_NONE) {
// packet was successfully received
Serial.println(F("success!"));
// print the data of the packet
Serial.print(F("[SX1262] Data:\t\t"));
Serial.println(str);
// print the RSSI (Received Signal Strength Indicator)
// of the last received packet
Serial.print(F("[SX1262] RSSI:\t\t"));
Serial.print(radio.getRSSI());
Serial.println(F(" dBm"));
// print the SNR (Signal-to-Noise Ratio)
// of the last received packet
Serial.print(F("[SX1262] SNR:\t\t"));
Serial.print(radio.getSNR());
Serial.println(F(" dB"));
// print frequency error
Serial.print(F("[SX1262] Frequency error:\t"));
Serial.print(radio.getFrequencyError());
Serial.println(F(" Hz"));
} else if (state == RADIOLIB_ERR_RX_TIMEOUT) {
// timeout occurred while waiting for a packet
Serial.println(F("timeout!"));
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
// packet was received, but is malformed
Serial.println(F("CRC error!"));
} else {
// some other error occurred
Serial.print(F("failed, code "));
Serial.println(state);
}
}
Thanks! |
This is amazing! I just bought a couple of the Pico Waveshare SX1262 (433 Mhz) boards and ran into the same Error-2 condition. Can't wait to try the solutions provided here - thanks everyone!! -Scott, K4KDR |
add support for Pi_Pico_1262_LoRa module (fix from from jgromes#729). LoRa hardware is --> https://www.waveshare.com/pico-lora-sx1262-868m.htm (choose appropriate model for your regional frequency bandplan)
add support for Pi_Pico_1262_LoRa module (fix from from jgromes#729). LoRa hardware is --> https://www.waveshare.com/pico-lora-sx1262-868m.htm (choose appropriate model for your regional frequency bandplan)
add support for Pi_Pico_1262_LoRa module (fix from from jgromes#729). LoRa hardware is --> https://www.waveshare.com/pico-lora-sx1262-868m.htm (choose appropriate model for your regional frequency bandplan)
add support for Pi_Pico_1262_LoRa module (fix from from jgromes#729). LoRa hardware is --> https://www.waveshare.com/pico-lora-sx1262-868m.htm (choose appropriate model for your regional frequency bandplan)
add support for Pi_Pico_1262_LoRa module (fix from from jgromes#729). LoRa hardware is --> https://www.waveshare.com/pico-lora-sx1262-868m.htm (choose appropriate model for your regional frequency bandplan)
add support for Pi_Pico_1262_LoRa module (fix from from jgromes#729). LoRa hardware is --> https://www.waveshare.com/pico-lora-sx1262-868m.htm (choose appropriate model for your regional frequency bandplan)
add support for Pi_Pico_1262_LoRa module (fix from from jgromes#729). LoRa hardware is --> https://www.waveshare.com/pico-lora-sx1262-868m.htm (choose appropriate model for your regional frequency bandplan)
Hi,
I am new to the LoRa/ microcontroller business and try to make 2 raspberry pico to communicate via LoRa or FSK. Therfore i bought a Waveshare SX1262 Shield (https://www.waveshare.com/pico-lora-sx1262-868m.htm) and use the Arduino IDE with Arduino MBED RP2040 Board chosen.
When compiling the SX126X examples of RadioLib, I get the failed, code -2.
I changed the Ports as shown in the waveshare link (SX1262 radio = new Module(5, 26, 20, 4);)
What am I doing wrong? Thanks alot in advance!
The text was updated successfully, but these errors were encountered: