Coder Social home page Coder Social logo

arduino-lora's Introduction

Arduino LoRa

Build Status

An Arduino library for sending and receiving data using LoRa radios.

Compatible Hardware

Semtech SX1276/77/78/79 wiring

Semtech SX1276/77/78/79 Arduino
VCC 3.3V
GND GND
SCK SCK
MISO MISO
MOSI MOSI
NSS 10
NRESET 9
DIO0 2

NSS, NRESET, and DIO0 pins can be changed by using LoRa.setPins(ss, reset, dio0). DIO0 pin is optional, it is only needed for receive callback mode. If DIO0 pin is used, it must be interrupt capable via attachInterrupt(...).

NOTES:

  • Some boards (like the Arduino Nano), cannot supply enough current for the SX127x in TX mode. This will cause lockups when sending, be sure to use an external 3.3V supply that can provide at least 120mA's when using these boards.
  • If your Arduino board operates at 5V, like the Arduino Uno, Leonardo or Mega, you will need to use a level converter for the wiring to the Semtech SX127x module. Most Semtech SX127x breakout boards do not have logic level converters built-in.

Installation

Using the Arduino IDE Library Manager

  1. Choose Sketch -> Include Library -> Manage Libraries...
  2. Type LoRa into the search box.
  3. Click the row to select the library.
  4. Click the Install button to install the library.

Using Git

cd ~/Documents/Arduino/libraries/
git clone https://github.com/sandeepmistry/arduino-LoRa LoRa

API

See API.md.

Examples

See examples folder.

FAQ

1) Initilizating the LoRa radio is failing

Please check the wiring you are using matches what's listed in Semtech SX1276/77/78/79 wiring. You can also use LoRa.setPins(ss, reset, dio0) to change the default pins used. Some logic level converters cannot operate at 8 MHz, you can call LoRa.setSPIFrequency(frequency) to lower the SPI frequency used by the library. Both API's must be called before LoRa.begin(...).

2) Can other radios see the packets I'm sending?

Yes, any LoRa radio that are configured with the same radio parameters and in range can see the packets you send.

3) Is the data I'm sending encrypted?

No, all data is sent unencrypted. If want your packet data to be encrypted, you must encrypt it before passing it into this library, followed by decrypting on the receiving end.

4) How does this library differ from LoRaWAN libraries?

This library exposes the LoRa radio directly, and allows you to send data to any radios in range with same radio parameters. All data is broadcasted and there is no addressing. LoRaWAN builds on top of LoRA, but adds addressing, encryption, and additional layers. It also requires a LoRaWAN gateway and LoRaWAN network and application server.

5) Does this library honor duty cycles?

No, you have to manage it by your self.

6) Which frequencies can I use?

You can use this table to lookup the available frequencies by your country. The selectable frequency also depends on your hardware. You can lookup the data sheet or ask your supplier.

Please also notice the frequency dependent duty cycles for legal reasons!

License

This libary is licensed under the MIT Licence.

arduino-lora's People

Contributors

antelder avatar boba0514 avatar dontsovcmc avatar facchinm avatar hema2-official avatar iotthinks avatar morganrallen avatar paraphraser avatar per1234 avatar pl125 avatar ricaun avatar rotzbua avatar sandeepmistry avatar sergio303 avatar tigoe avatar torntrousers avatar tromas71 avatar universam1 avatar w-ockham avatar yannikw avatar zbx-sadman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino-lora's Issues

Arduino Nano stops sending after 1 or 2 packets

I've hooked up an RFM95W to an Arduino Uno, a Wemos D1 Mini and an Arduino Nano. This library works well with the Uno and Wemos. The simple Sender and Receiver examples work as expected. But on Nanos (I've tried several) it's fine receiving but when I run the sender it transmits the first packet, and displays the Serial debug message for the second packet, but fails to transmit it, and then just hangs there doing nothing. The on-board LED stops blinking and remains solid - is this something odd with the SPI clock and pin 13 LED on the Nano?

Simple answer - use anything but a Nano. But I'm hoping there's a better solution. :)

The Lora.endPacket() gets stuck during the second pass

Hello Sandeep
I added these Serial.println for debugging in the Library:
{
Serial.println("LoRaClass::endPacket: before writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_TX);");
// put in TX mode
writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_TX);

Serial.println("LoRaClass::endPacket: before while((readRegister(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) == 0);");
// wait for TX done
while((readRegister(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) == 0);

// clear IRQ's
Serial.println("LoRaClass::endPacket before writeRegister(REG_IRQ_FLAGS, IRQ_TX_DONE_MASK);");
writeRegister(REG_IRQ_FLAGS, IRQ_TX_DONE_MASK);

return 1;
}

*************When I run the program this is what I get: ***********************

LoRa Sender
7
From the Library Definintion version = 9
Sending packet: 0
LoRaClass::endPacket: before writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_TX);
LoRaClass::endPacket: before while((readRegister(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) == 0);
LoRaClass::endPacket before writeRegister(REG_IRQ_FLAGS, IRQ_TX_DONE_MASK);
Sending packet: 1
LoRaClass::endPacket: before writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_TX);
LoRaClass::endPacket: before while((readRegister(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) == 0);

So it appeared it never leaves this while
while((readRegister(REG_IRQ_FLAGS) & IRQ_TX_DONE_MASK) == 0);
Regards

What is the function of LoRa.flush()?

Hi,

I am reading your LoRa.h. But I cannot find out the description about LoRa.flush() from API.md.

Could you give me more info about it?

Many thanks.

Block/Freeze when sending packet

Hi, my sketch it stop working when it reaches this lines:

  LoRa.beginPacket();                   // start packet
  LoRa.print(outgoing);                 // add payload
  LoRa.endPacket();                     // finish packet and send it

Do anybody had this issue before?

The example works OK, but when i adapt to my code, it blocks in this lines, it doesn't even send the packet.

one question

please answer this...
is necessary use level converter for spi in arduino uno board and lora ra 02 module ?

Compiling for IOT2020

Hello,

I'm trying to compile the LoRa Receiver example on a Simatic IOT2020 (which is basically a intel Galileo Gen2), but during the compiling I get these issuses:

C:\Users\hladik\Documents\Arduino\libraries\SPI.h/SPI.h:1843:8: error: 'SPIClass' does not name a type

C:\Users\hladik\Documents\Arduino\libraries\LoRa.h/LoRa.h:74:3: error: 'SPISettings' does not name a type

Could somebody help me with this?

By the way: when I compile it for a Arduino Mega 2560 everything runs propertly.

Transmission and recieved problems.

i used lora sx1278 thinker ra-2 to make a system. having lora master and 2 lora slaves.
but i can't receive feedback message from slave when i sent message from master. i think it has some conflict when Transmissing and receiving. here is code, i just copy and past and fixed a bit
master:

#include <SPI.h>
#include <LoRa.h>
String outgoing;              // outgoing message
byte msgCount = 0;            // count of outgoing messages
byte localAddress = 0xFF;     // address of this device
byte destination = 0xBB; 
void setup() {
  Serial.begin(9600);
  while (!Serial);
  Serial.println("LoRa Receiver");
  LoRa.setPins(10,9,2);
  LoRa.setSPIFrequency(1E6);
  LoRa.begin(433E6);
//  int ok=0;
//do
//{
//  delay(2000);
//  if (!LoRa.begin(433E6)) {
//    Serial.println("Starting LoRa failed!");
//    ok=0;
//  }
//  else
//  {
//    ok=1;
//  }
//}
//while(!ok);
  while(!LoRa.begin(433E6))
    {
      Serial.println("Starting LoRa failed!");delay(1000);
    }
}
void loop() {
  // try to parse packet
//  int packetSize = LoRa.parsePacket();
//  if (packetSize) {
//    // received a packet
//
//    Serial.print("Received packet '");
//
//    // read packet
//    while (LoRa.available()) {
//       Serial.print((char)LoRa.read());
//    }
//    // print RSSI of packet
//    Serial.print("' with RSSI ");
//    Serial.println(LoRa.packetRssi());
//  }
//  delay(100);
onReceive(LoRa.parsePacket()); delay(500);
if(incoming == "ask1")
{
   outgoing="ok";
  sendMessage(outgoing);
  }
}
void onReceive(int packetSize) {
  if (packetSize == 0) return;          // if there's no packet, return

  // read packet header bytes:
  int recipient = LoRa.read();          // recipient address
  byte sender = LoRa.read();            // sender address
  byte incomingMsgId = LoRa.read();     // incoming msg ID
  byte incomingLength = LoRa.read();    // incoming msg length
  String incoming = "";
                            // skip rest of function
  while (LoRa.available()) {
    incoming += (char)LoRa.read(); 
  }
  if (incomingLength != incoming.length()) {   // check length for error
    Serial.println("error: message length does not match length");
    return;                             // skip rest of function
  }                            // skip rest of function
    if (sender != 0xBB && recipient != 0xFF) {
    Serial.println("This message is not for me.");
    return; }
 
   Serial.println("Received from:" + String(sender, HEX));
   Serial.println("Sent to:" + String(recipient, HEX));
   Serial.println("Message ID:" + String(incomingMsgId));
   Serial.println("Message length:" + String(incomingLength));
   Serial.println("Message:" + incoming);
   Serial.println("RSSI:" + String(LoRa.packetRssi()));
   Serial.println("Snr:" + String(LoRa.packetSnr()));
   Serial.println(); 
}
void sendMessage(String outgoing){
    LoRa.beginPacket();
    LoRa.write(destination);
    LoRa.write(localAddress);
    LoRa.write(msgCount);
    LoRa.write(outgoing.length());   
    LoRa.print(outgoing);
    LoRa.endPacket();        
    msgCount++; 
 }

and slave:

#include <SPI.h>
#include <LoRa.h>
String outgoing;              // outgoing message
byte msgCount = 0;            // count of outgoing messages
byte localAddress = 0xFF;     // address of this device
byte destination = 0xBB; 
void setup() {
  Serial.begin(9600);
  while (!Serial);
  Serial.println("LoRa Receiver");
  LoRa.setPins(10,9,2);
  LoRa.setSPIFrequency(1E6);
  LoRa.begin(433E6);
//  int ok=0;
//do
//{
//  delay(2000);
//  if (!LoRa.begin(433E6)) {
//    Serial.println("Starting LoRa failed!");
//    ok=0;
//  }
//  else
//  {
//    ok=1;
//  }
//}
//while(!ok);
  while(!LoRa.begin(433E6))
    {
      Serial.println("Starting LoRa failed!");delay(1000);
    }
}
void loop() {
  // try to parse packet
//  int packetSize = LoRa.parsePacket();
//  if (packetSize) {
//    // received a packet
//
//    Serial.print("Received packet '");
//
//    // read packet
//    while (LoRa.available()) {
//       Serial.print((char)LoRa.read());
//    }
//    // print RSSI of packet
//    Serial.print("' with RSSI ");
//    Serial.println(LoRa.packetRssi());
//  }
//  delay(100);
onReceive(LoRa.parsePacket()); delay(500);
if(incoming == "ask1")
{
   outgoing="ok";
  sendMessage(outgoing);
  }
}
void onReceive(int packetSize) {
  if (packetSize == 0) return;          // if there's no packet, return

  // read packet header bytes:
  int recipient = LoRa.read();          // recipient address
  byte sender = LoRa.read();            // sender address
  byte incomingMsgId = LoRa.read();     // incoming msg ID
  byte incomingLength = LoRa.read();    // incoming msg length
  String incoming = "";
                            // skip rest of function
  while (LoRa.available()) {
    incoming += (char)LoRa.read(); 
  }
  if (incomingLength != incoming.length()) {   // check length for error
    Serial.println("error: message length does not match length");
    return;                             // skip rest of function
  }                            // skip rest of function
    if (sender != 0xBB && recipient != 0xFF) {
    Serial.println("This message is not for me.");
    return; }
 
   Serial.println("Received from:" + String(sender, HEX));
   Serial.println("Sent to:" + String(recipient, HEX));
   Serial.println("Message ID:" + String(incomingMsgId));
   Serial.println("Message length:" + String(incomingLength));
   Serial.println("Message:" + incoming);
   Serial.println("RSSI:" + String(LoRa.packetRssi()));
   Serial.println("Snr:" + String(LoRa.packetSnr()));
   Serial.println(); 
}
void sendMessage(String outgoing){
    LoRa.beginPacket();
    LoRa.write(destination);
    LoRa.write(localAddress);
    LoRa.write(msgCount);
    LoRa.write(outgoing.length());   
    LoRa.print(outgoing);
    LoRa.endPacket();        
    msgCount++; 
 }

thanks alot.

problem with "set output power" in module inAir4 (and inAir9)

Hello.

Exists a problem at set output power when it's used the LoRa modules inAir4 and inAir9.

The register REG_PA_CONFIG (0x09) bit 7 select PA the output pin for the switch U5 (PE4259), but the pin PA_boost (sx1276) it's not conected at switch, you must use the RFO_LF pin to transmit with this module.

itis necesary change line 40 "#define PA_BOOST 0x80" for "#define PA_BOOST 0x70" (only in this case).

I prove write a 0x7e in RegPaConfig, the range increase at 400 meters in urban enviroment.
the max power transmit isn't posible with this modules.

thank and regard, the library is very useful.

Different bandwidths

I'm using 433 as a frequency but can't seem to change the bandwidth to anything lower than the default, any ideas?

Led pin 13 overridden on Nano board?

So, As soon as I use LoRa.begin()

I Lose control of pin 13 on my Clone Nano... I checked and the blink sketch works just fine. Is there a reason for this I didn't see any off hand looking at the code but I may have missed something?

need urgent help

can this library work for sx1272 chip..if yes/no how can i make it work. the library and examples are very good and straightforward unlike other lora libraries. but i have sx1272 and and i want to use the this library and examples on my chip. please revert back as soon. thanks in advance.
s1272.pdf

Lora.begin() problem

I would like refresh this theme,
I try start LoRa but don't have any success.
I connect LoRa module RFM95 (Hoperf electronic) . I try with logic level converter and without him, . I have UNO, module Connect 3.3v from arduino and external source 3.3v and nothing.
All time I received 0 ( zero) from module.

any idea ? PLEASE

Send struct

Can you add an example of how to send and receive a structure?

Problem to initialize LoRa with nodemcu.

Hi!

When I start LoRa, (! LoRa.begin (868E6)) my nodemcu does not start, I press the reset and it restarts itself. If I remove the LoRa boot from the program, it stops reinitializing. What could it be?

I tested it with 2 arduinos and it works. I used the example scketchs from the LoRa library.
lora_esp
erro esp2

Bad LoRa Range with electron Particle.

Hi Everyone,

I am using an electron with a SX1276 lora module to act as a receiver and I'm having a strange issue.

When I connect up the LoRa module to a Arduino mini, I get good range (100m in built up city).

When I connect up the electron to the same LoRa module the range drops to about 25m.
any idea why this might be?

Here are the reg dumps from both setups:

ok here's the arduino
LoRa Dump Registers
0x0: 0x44
0x1: 0x81
0x2: 0x1A
0x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
0x5A: 0xC
0x5B: 0x0
0x5C: 0x7
0x5D: 0x0
0x5E: 0x5C
0x5F: 0x78
0x60: 0x0
0x61: 0x1C
0x62: 0xE
0x63: 0x5B
0x64: 0xCC
0x65: 0x0
0x66: 0x1
0x67: 0x50
0x68: 0x0
0x69: 0x0
0x6A: 0x0
0x6B: 0x0
0x6C: 0x0
0x6D: 0x0
0x6E: 0x0
0x6F: 0xB
0x70: 0xD0
0x71: 0x0
0x72: 0x13
0x73: 0x0
0x74: 0x0
0x75: 0x0
0x76: 0x0
0x77: 0x0
0x78: 0x0
0x79: 0x0
0x7A: 0x0
0x7B: 0x0
0x7C: 0x0
0x7D: 0x0
0x7E: 0x0
0x7F: 0x0

Starting Lora failed

I am using two ARDUINO board MEGA and UNO.
Using two SX1278 module to send data back and forth.
I included Lora library and using the Sender and receiver example.
But
at the
if (!LoRa.begin(434E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
I am getting this message in the Serial Monitor That Starting Lora failed. I changed the frequency too.

saving pins ss and reset

Pins on ESP8266 platform are expensive.
Reading through your great library I assume that the pins ss and reset could be omitted- optionally!

SS could be pulled down permanently if single SPI device.
Reset could be wired to ESP8266 reset pin and get resetted at boot.
A little support by library would be required I could provide and test.
What do you think about?

Issue of transreception

Here i am wrking on project of sending and receiving gps data using 2 lora sx1276. Here i am able to either send or receive the data. But i need both transreception at same time and also in continous transreception form i.e., both must be sending and receiving gps data the whole time when its switched on. Can you please help me out. Thanks in advance

How to receive and send at the same time?

Hi, how to receive and send at the same time?
I put the example in the reception and send written together, but still can not get the results I want.
I need your help.
Thank you!

Not an Issue - LoRa Shield Update

Thank you for the library, and work you have done on this.
I am currently doing some tests and getting some pretty amazing results.
So this is just for your information - Linksprite's LoRa Shield also works with the library
(it does appear to use PIN 2 for interrupt)
It is using the RF96 chip.
It appears to be very similar to the Dragino LoRa Shield.
Your library is the only one that I got to work with my boards BTW - the sketch that Linksprite provides doesn't compile. Beyond what you need to know: (I suspect it has something to do with the IDE they used, but even using the one they have pictured, I got weird errors)
Here is a link to some information that is helpful for the Linksprites shield
http://linksprite.com/wiki/index.php5?title=DIY_low-cost_LoRa_gateway_based_on_pcDuino#2._Program_Arduino_Uno

Thanks again.

how we can set address to lora module.

i want to work with 3 lora modules. all 3 should have address. so that i can send the data from 3 lora modules to another lora module is 4 rth one. so how i can give address to particular lora module.

About the range and configuration

Hello Sandeep,

First of all I would like to congratulate you for your contributtion with this LoRa library!

Probably this post it's not a real issue, actually is just a couple of questions.

I have some questions about this library/implementation;

  1. Could you tell me about the range using the SX1286 (with Adafruit breakout board)? I did some tests and I got 700 meters at maximum.

  2. Have you perfomed any latence test with the examples codes?

Thank you very much

Cheers!

Poor RSSI

Hi - thanks for this library. I have been using other libraries to drive my inAIR9 modules (SX1276) and it was working just fine but is overly complex. I can reach several km no problem. However, when I use your library, I can't even reach 10m! Reported RSSI when the tx & rx are side-by-side is -95! And the messages die less than 10m apart. I'm using your examples with some code to ensure parameters are set the same as I was using previously.

  if (!LoRa.begin(92252E4)) {
   Serial.println("Starting LoRa failed!");
   while (1);
 }
 else
   Serial.println("Started LoRa OK");
 LoRa.setSpreadingFactor(12);           // ranges from 6-12,default 7 see API docs
 LoRa.setTxPower(17);
 LoRa.setSignalBandwidth(125E3);
 LoRa.setCodingRate4(5);

Any ideas?

Sync word issue

Sync word checking appears to be inconsistent. (I'm using a variation of the LoRaReceive sketch here, not the callback sketch). What follows is a set of collected findings and questions, but unfortunately not a solution (sorry).

Using two radios, I set the sync word of one to 0xAA and the other variable. I ran through all values from 0x01 to 0xFF. The following "matched" with 0xAA:

a8, a7, a6, a5, a4, a3, a2, a1, a0, 9d, a8, a9, aa, ab, ac, ad, ae, af, b0, b3, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae, af, b0, b3, b4, b5, b9, bc, c3, c5, c6, c9, ca, d3, d6, d7, d9, e3, e8, ea, f0, f7, 13, 1a, 2c, 2f, 33, 36, 39, 3a, 43, 44, 45, 46, 4f, 5d, 67, 69, 6f, 70, 7a, 7c, 7f, 88, 89, 8e, 94, 95, 9e, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae, af, b0

It seems like the device should be in sleep mode when you set the sync word, so perhaps it would make sense to wrap the writeRegister() in setSyncWord() in a call to sleep mode, then return the radio to its normal mode before the function is over. Also, "The bit synchronizer must also be activated in Continuous mode (automatically done in Packet mode)" (from the Semtech datasheet), which makes me wonder if sync word detection doesn't work in single receive mode? The HopeRF datasheet is unclear on this, and doesn't even detail the LoRa mode registers.

It is worth noting somewhere in the docs that single receive mode is intended for battery operation, and continuous receive mode consumes more power, and is intended for non-battery operation.

Will test more when I've got the hardware in hand again.

how to get data from child lora devices to parent lora

I have tried the simple sender and receiver. its working fine. thank you for the detailed explanation.

i wold like to know how this communication is working with out mentioning any address to these devices. ?

and i wanted to know how the communication can be done from single to multiple lora devices ?

False intrrupt trigger in lora arduino

Hi Im facing false interrupt triggers in lora library. Im using a Arduino DIP IC at 3.3V on bread board and DRF1276F Lora module. Have attached the interrupt to pin number 2 and after some 2 hours of running im getting a false trigger and after that the controller hangs. I even tried to enable the WDT but still it hangs in between with false triggers. could you please help me with this. I have attached my code below.

#include <SPI.h>
#include <LoRa.h>
#include <avr/wdt.h>

#define NODE_ID 1
int counter = 0;
const byte numChars = 40;
char receive_buff[numChars];
char tempChars[numChars];        // temporary array for use by strtok() function
int from_address,to_address,firstArg,secondArg;
boolean loradata = false;
boolean newData = false;
boolean command_make_flag = false;
boolean pw_command_flag = false;
boolean ack_received_flag = false;
boolean read_command_flag = false;
boolean pr_command_flag = false;
char commandFromPC[10];
char pactet_type;
int pactet_number,soil_moisture,luminocity_val;
float temperature_val,humidity_val,pressure_val;
int port_state;

void setup() 
{
  pinMode(8,OUTPUT);
  pinMode(7,OUTPUT);
  digitalWrite(2, INPUT_PULLUP);    // Turn on internal Pull-Up Resistor
  Serial.begin(9600);
  while (!Serial);
  
  Serial.println("LoRa Receiver Callback");

  if (!LoRa.begin(915E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }

  // register the receive callback
  LoRa.onReceive(onReceive);

  // put the radio into receive mode
  LoRa.receive();
  wdt_enable(WDTO_8S);
}
unsigned long now = millis();
unsigned long now1 = millis();
void loop() 
{
  // do nothing
  scan_flag();
  digitalWrite(7,HIGH);
  delay(50);
  digitalWrite(7,LOW);
  delay(50);
  wdt_reset();  

  while(millis() - now > 60000)
  {
        LoRa.beginPacket();
        LoRa.print("<1,0,0,22.76,45.3,911.76,433,250>");
//        LoRa.print(counter);
        LoRa.endPacket();
        LoRa.receive();
        Serial.println("<1,0,0,22.76,45.3,911.76,433,250>");
        now = millis();
  }

  while(millis() - now1 > 33000)
  {
    char message[20];    
    port_state = digitalRead(8);         
    sprintf(message,"<%d,%d,2,%d>",NODE_ID,from_address,port_state);
    LoRa.beginPacket();
    LoRa.print(message);
    LoRa.endPacket();
    LoRa.receive(); 
    Serial.println(message);
    now1 = millis();
  }
}

void onReceive(int packetSize) 
{
  int i = 0;
  // received a packet
  Serial.print("Received packet '");

  // read packet
  Serial.println(packetSize);

  for ( i = 0; i < packetSize; i++) 
  {
    receive_buff[i] = (char)LoRa.read();
  }
  i++;
  receive_buff[i] = '\0';
  // print RSSI of packet
  Serial.print("' with RSSI ");
  Serial.println(LoRa.packetRssi());
  loradata = true;
}


void scan_flag()
{
  
//  Serial.println("In Scan fun");
  if(loradata == true)
  {
//    Serial.println("lora data true");
    recvWithStartEndMarkers();
    loradata = false;
  }

  if(newData == true)
  {
   parseData();
   newData = false;
  }

  if(command_make_flag == true)
  {
    
    command_make();
//    command_make_flag = true;
  }

  if(pw_command_flag == true)
  {
    Serial.println("In PW command");
    digitalWrite(firstArg,secondArg); 
    pw_command_flag = false;
  }

//  if(read_command_flag == true)
//  {
//    Serial.println("In READ command");
////    readsoil();
//
//    sprintf(message,"<1,0,0,22.76,45.3,911.76,433,250>");
//    sendmsg();
//    read_command_flag = false;
//  }
//   if(pr_command_flag == true)
//  {
//    Serial.println("In PORT READ command");
////    readsoil();
//    port_state = digitalRead(firstArg);
//    sprintf(message,"<%d,%d,2,%d>",NODE_ID,from_address,port_state);
//    sendmsg();
//    pr_command_flag = false;
//  }
  
}


void parseData() 
{
//    Serial.print("In Parse Fun");
      // split the data into its parts
    char * strtokIndx; // this is used by strtok() as an index 
//   strcpy(tempChars, receive_buff);
//  strcpy(messageFromPC, strtokIndx); // copy it to messageFromPC    
//  integerFromPC = atoi(strtokIndx);     // convert this part to an integer

    strtokIndx = strtok(tempChars,",");      // get the first part - the string
    from_address = atoi(strtokIndx);     // convert this part to a float
  
    strtokIndx = strtok(NULL, ","); // this continues where the previous call left off
    to_address = atoi(strtokIndx);     // convert this part to a int
//    if(to_address == NODE_ID)
//    { 
      strtokIndx = strtok(NULL, " ");
      strcpy(commandFromPC, strtokIndx);     // convert this part to a float
  
      strtokIndx = strtok(NULL, " ");
      firstArg = atoi(strtokIndx);     // convert this part to a float
  
      strtokIndx = strtok(NULL, " ");
      secondArg = atoi(strtokIndx);

      Serial.print("From Addr is ");
      Serial.print(from_address);
      Serial.print("\n");
      Serial.print("To Addr is ");
      Serial.print(to_address);
      Serial.print("\n");
      Serial.print("Command is ");
      Serial.print(commandFromPC);
      Serial.print("\n");
      Serial.println("First arg is ");
      Serial.print(firstArg);
      Serial.print("\n");
      Serial.println("second arg is ");
      Serial.print(secondArg);
      Serial.print("\n");
   
      newData = false;
      command_make_flag = true;
//    }
    
}


void recvWithStartEndMarkers()
{
//    Serial.println("In receive fun");
    static boolean recvInProgress = false;
    static byte ndx = 0;
    char startMarker = '<';
    char endMarker = '>';
    char rc;
//    Serial.println("In Receive Fun");
    while (loradata == true)
    {
//      Serial.println("In receive while loop");
        rc = receive_buff[ndx];
//        Serial.println(rc);
        if (recvInProgress == true)
        {
//          Serial.println("receive progress");
            if (rc != endMarker) 
            {
                tempChars[ndx-1] = rc;
//                Serial.println(tempChars[ndx]);
                ndx++;
                if (ndx >= numChars)
                {
                    ndx = numChars - 1;
                }
            }
            else
            {
                tempChars[ndx-1] = '\0'; // terminate the string
                recvInProgress = false;
                ndx = 0;
                newData = true;
                loradata = false;
            }
        }

        else if (rc == startMarker) 
        {
            recvInProgress = true;
            ndx++;
        }
//        yield();
    }
    Serial.println("Received data is");
    Serial.println(receive_buff);
    Serial.println("Parsed data is");
    Serial.println(tempChars);   
//    Serial.println("Size of Parsed data is");
//    Serial.println(sizeof(tempChars));
//  Serial.println(sizeof(receivedChars));
  
}

void command_make()
{             
       if(strcmp(commandFromPC, "PW") == 0)
      {
        Serial.println("In PW command");
        digitalWrite(firstArg,secondArg); 
        pw_command_flag = false;
      }

      if(strcmp(commandFromPC, "READ") == 0)
      {
        Serial.println("Command is READ");
//        delay(1000);
        LoRa.beginPacket();
        LoRa.print("<1,0,0,22.76,45.3,911.76,433,250>");
        LoRa.print(counter);
        LoRa.endPacket();
        LoRa.receive();
//        read_command_flag = true; 
      }
//
//      if(strcmp(commandFromPC, "PR") == 0)
//      {
////        Serial.println("Command is PORT READ");
//        pr_command_flag = true; 
//      }
      
      command_make_flag = false;
}

LoRa Low Power

Hey, I'm trying to set the sender to a low power mode either sleep or standby. The problem I'm having is that when i try to put the device in sleep or standby mode I see no reduction in power consumption on my multimeter... Anyone else experience this?

// temp = analogRead(thermistorpin);
Serial.print("current temp: ");
Serial.println(t);
LoRa.beginPacket();
LoRa.print(t);
LoRa.endPacket();
delay(2000);
// send packet
LoRa.beginPacket();
LoRa.print(t);
LoRa.endPacket();
counter++;
delay(5000);
/* Don't forget to clear the flag. /
f_wdt = 0;
LoRa.sleep();
Serial.println("Lorasleep");
/
Re-enter sleep mode. */
enterSleep();

Point to MultiPoint

Dear Sandeep mistry,

can i make point to multi point communication using this library? if yes than how i can?
i am making student project using LoRa in which i have to send data from one master unit to multiple slave units.
So, Please Help me.

Thanks and Regards,
Darshit

Initialization failed

I set up two Lora radios using the RH_RF95 library. I used two Arduino MKR1000 and two Adafruit RFM95W radios. My system works but I found your Library much cleaner and easier to use. But when I installed it and set the pins LoRa.setPins(7,2,1); which is the same setting I used for the other library and run the program I get: "Starting LoRa failed!".
Can you help me debug/determine what is wrong?
Thanks

LoRa 1 channel gateway

There is a way to block a node to a certain channel? I know with the LMIC IBM library you can. I have a one channel DIY gateway running on a Raspberry Pi, and I would like to block my node only to Channel 0 (868.1MHz) using that library I love.

Thanks!

AES encryption

Hey @sandeepmistry,
it is not really an issue, but I would like to know if you planning to add AES encryption to your library.
I really like the configuration options, but I'm missing the encryption part.

Hello my Friend San

Good Afternoon My friend

I have a couple of RN2903 modules.
I want to connect them and transmit. Can I use the code to send and receive that you uploaded here? My modules have a frequency of 915 MHz.
Do you have a diagram to connect them?

I thank you, my friend.

LoRa failed to initialize- how to debug?

I have an AI-Thinker RA-02 (SX1278) on a LoRa32u4 board, which won't initialise. I've tried multiple modules and checked the pins are correct using LoRa.setPins()

How can I debug why it's not working?

For others with the LoRa32u4 I followed the following tutorial as I received it with no information!

https://goo.gl/kSGfyB

ESP32/ESP8266 Issues

Hi,
I have been working with your LoRaDuplex sketch and I ran into some issues.
I was able to get it running with a Leonardo with a Dragino LoRa radio, I was also able to get it running with a M0 basic Feather and LoRa Feather. When I tried to get it working with an ESP32 I could never get the radio initialized, and when I tried to get it running on an ESP8266 it would just keep resetting.
Soft WDT reset
ctx: cont
sp: 3ffef9f0 end: 3ffefbd0 offset: 01b0
>>>stack>>>
3ffefba0: 3fffdad0 3ffeea78 3ffeeb7c 40201f65
3ffefbb0: feefeffe 00000000 3ffeeb98 4020331c
3ffefbc0: feefeffe feefeffe 3ffeebb0 40100114
<<<stack<<<
I know the hardware works, but would there be an issue with the ESP32/ESP8266. I wouldn't think so but this has me stumped.
Any thoughts?

Thanks,

CRC not working

I've enabled CRC on sender and receiver but I still get bad packets when at the limits of range. Is enabling CRC meant to ignore bad packets or do I need to check it manually in the OnReceive callback? I can't find a function for that in this library or it's documentation.

Preamble issue

I'm trying to use one of 1276 module be a gateway and collect data from other nodes.
The example work greatly so far.
What I know about Lora is using the way like TDMA to avoid the collision.
Distribute the time and polling all nodes by gateway to get the data.
The nodes will sleep and wake up periodically and listen the preamble to judge if should reply or not.
Does the parameter of preamble need to set in both of gateway and nodes?
Is there any example? Thanks.

REG_SYNC_WORD is set to 0x39 datasheet calls for 0x28..0x2F

Thanks for making this lib available to everyone. It makes working with these modules more human readable.
I am working on a little payload computer for a high altitude balloon. I am using your lora library to communicate with the Pi in the sky gateway from here: https://github.com/PiInTheSky/lora-gateway
I keep getting crc error, but everything seems to match except for syncword. While looking more into this I notice that REG_SYNC_WORD may be set incorrectly to 0x39. Also REG_MODEM_3 (0x26) which if bit 3 (0x04) is set it greatly improve the reception for low data rate and noisy environments and long distances, but it is not set.

I am using the little module from 915 adafruit module which has the RFM96 IC although they said it should have the 95w. Anyways I am reading the datasheet from: http://www.hoperf.com/upload/rf/RFM95_96_97_98W.pdf (page 93 has the sync word registers listed).

Card possibilities

Your project arduino-LoRa is pretty interesting, the example of the sender an receiver are pretty well simplified :)

I have some questions :

I don't relay know what type of Arduino card I should use... I have got an Arduino Mega2560, Due, and 101, actually I don't really understand how we can connect an sx1276 LoRa card to any type of Arduino cards without making some pin definitions in the codes (in the setup() parts of the codes should I use the LoRa.setPins(ss, reset, dio0)function ?)

Thank you
Have a great day !

How to using the mode fsk for module RA-02.

I want to test some things, a performance comparison between fsk mode with lora mode. But the problem exactly define REGISTER for fsk mode, so I asked for advice, or write liberry fsk mode for me, please respond. THANK YOU.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.