Skip to content

Commit 8319d45

Browse files
committed
Merge remote-tracking branch 'upstream/master' into CAD-detection
2 parents d6ef9e1 + b4558aa commit 8319d45

File tree

3 files changed

+54
-13
lines changed

3 files changed

+54
-13
lines changed

API.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ LoRa.setPins(ss, reset, dio0);
3232

3333
This call is optional and only needs to be used if you need to change the default pins used.
3434

35+
#### No MCU controlled reset pin
36+
37+
To save further pins one could connect the reset pin of the MCU with reset pin of the radio thus resetting only during startup.
38+
39+
* `reset` - set to `-1` to omit this pin
40+
3541
### Set SPI Frequency
3642

3743
Override the default SPI frequency of 10 MHz used by the library. **Must** be called before `LoRa.begin()`.

README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build Status](https://travis-ci.org/sandeepmistry/arduino-LoRa.svg?branch=master)](https://travis-ci.org/sandeepmistry/arduino-LoRa)
44

5-
An [Arduino](http://arduino.cc/) library for sending and receiving data using [LoRa](https://www.lora-alliance.org/) radios.
5+
An [Arduino](https://arduino.cc/) library for sending and receiving data using [LoRa](https://www.lora-alliance.org/) radios.
66

77
## Compatible Hardware
88

@@ -27,7 +27,9 @@ An [Arduino](http://arduino.cc/) library for sending and receiving data using [L
2727

2828
`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(...)`](https://www.arduino.cc/en/Reference/AttachInterrupt).
2929

30-
**NOTE**: 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.
30+
**NOTES**:
31+
* 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.
32+
* 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.
3133

3234
## Installation
3335

@@ -53,6 +55,34 @@ See [API.md](API.md).
5355

5456
See [examples](examples) folder.
5557

58+
## FAQ
59+
60+
**1) Initilizating the LoRa radio is failing**
61+
62+
Please check the wiring you are using matches what's listed in [Semtech SX1276/77/78/79 wiring](#semtech-sx1276777879-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(...)`.
63+
64+
**2) Can other radios see the packets I'm sending?**
65+
66+
Yes, any LoRa radio that are configured with the same radio parameters and in range can see the packets you send.
67+
68+
**3) Is the data I'm sending encrypted?**
69+
70+
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.
71+
72+
**4) How does this library differ from LoRaWAN libraries?**
73+
74+
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.
75+
76+
**5) Does this library honor duty cycles?**
77+
78+
No, you have to manage it by your self.
79+
80+
**6) Which frequencies can I use?**
81+
82+
You can use [this table](https://www.thethingsnetwork.org/wiki/LoRaWAN/Frequencies/By-Country) 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.
83+
84+
Please also notice the frequency dependent duty cycles for legal reasons!
85+
5686
## License
5787

58-
This libary is [licensed](LICENSE) under the [MIT Licence](http://en.wikipedia.org/wiki/MIT_License).
88+
This libary is [licensed](LICENSE) under the [MIT Licence](https://en.wikipedia.org/wiki/MIT_License).

src/LoRa.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#define REG_FIFO_RX_CURRENT_ADDR 0x10
1818
#define REG_IRQ_FLAGS 0x12
1919
#define REG_RX_NB_BYTES 0x13
20+
#define REG_PKT_SNR_VALUE 0x19
2021
#define REG_PKT_RSSI_VALUE 0x1a
21-
#define REG_PKT_SNR_VALUE 0x1b
2222
#define REG_MODEM_CONFIG_1 0x1d
2323
#define REG_MODEM_CONFIG_2 0x1e
2424
#define REG_PREAMBLE_MSB 0x20
@@ -63,17 +63,19 @@ int LoRaClass::begin(long frequency)
6363
{
6464
// setup pins
6565
pinMode(_ss, OUTPUT);
66-
pinMode(_reset, OUTPUT);
67-
68-
// perform reset
69-
digitalWrite(_reset, LOW);
70-
delay(10);
71-
digitalWrite(_reset, HIGH);
72-
delay(10);
73-
7466
// set SS high
7567
digitalWrite(_ss, HIGH);
7668

69+
if (_reset != -1) {
70+
pinMode(_reset, OUTPUT);
71+
72+
// perform reset
73+
digitalWrite(_reset, LOW);
74+
delay(10);
75+
digitalWrite(_reset, HIGH);
76+
delay(10);
77+
}
78+
7779
// start SPI
7880
SPI.begin();
7981

@@ -141,7 +143,9 @@ int LoRaClass::endPacket()
141143
writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_TX);
142144

143145
// wait for TX done
144-
while((readRegister(REG_IRQ_FLAGS) & LORA_IRQ_FLAG_TX_DONE) == 0);
146+
while((readRegister(REG_IRQ_FLAGS) & LORA_IRQ_FLAG_TX_DONE) == 0) {
147+
yield();
148+
}
145149

146150
// clear IRQ's
147151
clearInterrupts(LORA_IRQ_FLAG_TX_DONE);
@@ -273,6 +277,7 @@ void LoRaClass::onReceive(void(*callback)(int))
273277
_onReceive = callback;
274278

275279
if (callback) {
280+
pinMode(_dio0, INPUT);
276281
setInterruptMode(0, LORA_IRQ_DIO0_RXDONE);
277282

278283
attachInterrupt(digitalPinToInterrupt(_dio0), LoRaClass::onDio0RiseRx, RISING);

0 commit comments

Comments
 (0)