riotnetwork / samr

Arduino port for ATSAMR34 microcontrollers. The ATSAMR34J18B is a SAML21J18B with internal SX1276 LoRa tranceiver
https://github.com/riotnetwork/samr
11 stars 8 forks source link

LoraSenderReceiver #1

Closed shaadmahmud closed 3 years ago

shaadmahmud commented 4 years ago

I was trying to have a Lora sender and receiver code with RAK4260. With few tweaks on Sandeeps Lora library, got it working, here is the updated sktech:

include

include

int counter = 0; void setup() { Serial.begin(9600); //while (!Serial); Serial.println("LoRa Sender"); pinMode(SX1276_TCXO_POWER_PIN ,OUTPUT); pinMode(SX1276_BAND_SEL_PIN ,OUTPUT); LoRa.setPins(SS,SX1276_RESET_PIN ,SX1276_DIO0 ); // I swapped the RF RST with VBat pin if (!LoRa.begin(915E6)) { Serial.println("Starting LoRa failed!"); while (1); } } void loop() { Serial.print("Sending packet: "); Serial.println(counter);

// send packet LoRa.beginPacket(); LoRa.print("hello "); LoRa.print(counter); LoRa.endPacket(); counter++; delay(1000); }

DanielRIOT commented 3 years ago

Yay, Thank you ! I'll see if I can add it as an Exampl

vslinuxdotnet commented 3 years ago

Hello, sorry to ask but what changes do you make in Sandeeps Lora library ? I get always "Starting LoRa failed!" with your example sktech. I use the WLR089U0 module.

Thank you

DanielRIOT commented 3 years ago

Hi @vslinuxdotnet , I have not made any changes to Sandeep's LoRa library, ( We use the MCCI LoRaWAN one in a few designs based on this module - https://github.com/mcci-catena/arduino-lmic ) the examples that work on a Adafruit LoRa feather also work on this port ( If you supply the correct GPIO to the library for Radio control signals ).

The SAMR34 is a SAML21 with a SX1276 on SERCOM4 ( SPI ) and some GPIO connected to it internally

I have not looked at Sandeep's library in quite some time, but it may have some debugging information that you can look at to see why you get the "Starting LoRa Failed" . I'll dig out my dev module and test it.

I don't have a WLR089U0 , but will go thru its pinout in the datasheet and see if i can add it as a target ( I think there is another open ticket for me to do that )

vslinuxdotnet commented 3 years ago

Hi @vslinuxdotnet , I have not made any changes to Sandeep's LoRa library, ( We use the MCCI LoRaWAN one in a few designs based on this module - https://github.com/mcci-catena/arduino-lmic ) the examples that work on a Adafruit LoRa feather also work on this port ( If you supply the correct GPIO to the library for Radio control signals ).

The SAMR34 is a SAML21 with a SX1276 on SERCOM4 ( SPI ) and some GPIO connected to it internally

I have not looked at Sandeep's library in quite some time, but it may have some debugging information that you can look at to see why you get the "Starting LoRa Failed" . I'll dig out my dev module and test it.

I don't have a WLR089U0 , but will go thru its pinout in the datasheet and see if i can add it as a target ( I think there is another open ticket for me to do that )

Hello, thank you for the report, indeed the problem was the pins defined and the return register from the lib. I solve the problem by set the pins, and add some code in the lib.

sketch: pinMode(20, OUTPUT); digitalWrite(20, HIGH); pinMode(18, OUTPUT); digitalWrite(18, HIGH); LoRa.setPins(27, SX1276_RESET_PIN, 21);// set CS, reset, IRQ pin

in the lib file Lora.cpp line:125 change

if (version != 0x12){
            return 0;
  }

to

 if (version != 0x12){
        if (version != 0x13)
            return 0;
  }

Thanks