sandeepmistry / arduino-LoRa

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

Arduino Uno, Ethernet shield W5100, Lora Shield Lora setPins doesn´t work #396

Closed fer-g3 closed 3 years ago

fer-g3 commented 4 years ago

Hi, I'm trying to use Arduino uno, ethernet shield w5100 and lora shield, I changed pins via setPins but I can´t get it work, everytime I run the code I get the same error Lora Init Failed. I changed jumper SV2, SV3, SV4 from right(default) to left according to this site information http://wiki.dragino.com/index.php?title=Lora_Shield. I also changed those lines referred to pins in file LoRa.h, but I hasn´t worked.

define LORA_DEFAULT_SS_PIN 10

define LORA_DEFAULT_RESET_PIN 9

`#include

include

define TX_PACKET_MAX_SIZE 9

define baud 9600

float lux = 0.f;

const int Lora_SS = 8; const int Lora_RST = 7; const int Lora_DIO0 = 2;

void setup() { pinMode(Lora_SS, OUTPUT); digitalWrite(Lora_SS, HIGH);

// override the default CS, reset, and IRQ pins (optional) LoRa.setPins(Lora_SS, Lora_RST, Lora_DIO0); // set CS, reset, IRQ pin
delay(200); Serial.begin(baud); // initialize serial while (!Serial);

if (!LoRa.begin(915E6)) { // initialize ratio at 915 MHz Serial.println("LoRa init failed. Check your connections."); while (true); // if failed, do nothing }
Serial.println("LoRa init succeeded."); }

String dataR = "";

void loop() { int packetSize = LoRa.parsePacket(); if(packetSize){ Serial.print("Dato Recibido");

while(LoRa.available()){
  dataR += ((char)LoRa.read());
}

// lux = dataR.toFloat(); Serial.println(); Serial.print("Lux "); Serial.println(dataR);

Serial.println();
Serial.print("Packet RSSI ");
Serial.println(LoRa.packetRssi());

Serial.print("Packet SNR: ");
Serial.println(LoRa.packetSnr());

} }`

IoTThinks commented 4 years ago

For Arduino, you may need to use the defined SPI CS/SS in Arduino board. And you may need to use an interruptable GPIO for your Arduino board.