sandeepmistry / arduino-LoRa

An Arduino library for sending and receiving data using LoRa radios.
MIT License
1.61k stars 621 forks source link

How to NOT USE DIO0? #601

Open ams-hh opened 1 year ago

ams-hh commented 1 year ago

Hello!

If I call LoRa.begin after having called LoRa.setPins(SS, RST, DIO0); with my configuration of Pins, everything works as desired. I can send and receive. (in the momeent) I do not need the callback facility and I have learned, that I in this case do not need DIO0. But how to define this? When I call LoRa.setPins(SS, RST; or LoRa.setPins(SS, RST, -1);

AND DO NOT WIRE the DIO0 pin of the module, LoRa.begin fails. Very weired: IF I WIRE DIO0 with a pin of the ESP (using ESPS3-Wroom-1) everything works again. Even if the software cannot know of any pin with funcionality for DIO0???

Is it a problem of the open DIO0 Pin of the module? Or what do I miss?

Thanks Andree

Kongduino commented 1 year ago

The library has a LORA_DEFAULT_DIO0_PIN, but its value varies:

#if defined(ARDUINO_SAMD_MKRWAN1300)
[...]
#define LORA_DEFAULT_DIO0_PIN      -1
#elif defined(ARDUINO_SAMD_MKRWAN1310)
[...]
#define LORA_DEFAULT_DIO0_PIN      LORA_IRQ
#else
[...]
#define LORA_DEFAULT_DIO0_PIN      2
#endif

So depending on your MCU, it might be a different value.

void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN);

This uses the LORA_DEFAULT_DIO0_PIN setting by default, but you can override it by passing -1. But you seem to say that this fails. Since a lot of the code passes _dio0 as a parameter, depending on the MCU this might break things. You didn't mention the MCU you were using...

I have used -1 without issues on some boards, but most of the time I want DIO0 wired. But in any case, just wire one pin and forget it, that'll solve your problem.

ams-hh commented 1 year ago

"You didn't mention the MCU you were using..."

I did. See above: "(using ESPS3-Wroom-1"