Skip to content

Commit d690d79

Browse files
committed
Add initial documentation
1 parent 1fb8b29 commit d690d79

File tree

2 files changed

+185
-2
lines changed

2 files changed

+185
-2
lines changed

API.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# LoRa API
2+
3+
## Include Library
4+
5+
```arduino
6+
#include <LoRa.h>
7+
```
8+
9+
## Setup
10+
11+
### Begin
12+
13+
Initialize the library with the specified frequency.
14+
15+
```arduino
16+
LoRa.begin(frequency);
17+
```
18+
* `frequency` - frequency in Hz (`433E6`, `866E6`, `915E6`)
19+
20+
Returns `1` on success, `0` on failure.
21+
22+
## Set pins
23+
24+
Override the default `NSS` and `NRESET` pins used by the library. **Must** be called before `LoRa.begin()`.
25+
26+
```arduino
27+
LoRa.setPins(ss, reset);
28+
```
29+
* `ss` new slave select pin to use, defaults to `10`
30+
* `reset` new reset pin to use, defaults to `9`
31+
32+
### End
33+
34+
Stop the library
35+
36+
```arduino
37+
LoRa.end()
38+
```
39+
40+
## Sending data
41+
42+
### Begin packet
43+
44+
Start the sequence of sending a packet.
45+
46+
```arduino
47+
LoRa.beginPacket();
48+
```
49+
50+
Returns `1` on success, `0` on failure.
51+
52+
### Writing
53+
54+
Write data to the packet. Each packet can contain up to 255 bytes.
55+
56+
```arduino
57+
LoRa.write(byte);
58+
59+
LoRa.write(buffer, length);
60+
```
61+
* `byte` single byte to write to packet
62+
63+
or
64+
65+
* `buffer` data to write to packet
66+
* `length` size of data to write
67+
68+
Returns the number of bytes written.
69+
70+
**Note:** Other Arduino `Print` API's can also be used to write data into the packet
71+
72+
### End packet
73+
74+
End the sequence of sending a packet.
75+
76+
```arduino
77+
LoRa.endPacket()
78+
```
79+
80+
Returns `1` on success, `0` on failure.
81+
82+
## Receiving data
83+
84+
### Parsing packet
85+
86+
Check if a packet has been received.
87+
88+
```arduino
89+
int packetSize = LoRa.parsePacket();
90+
```
91+
92+
Returns the packet size or `0` if no packet was received.
93+
94+
### Packet RSSI
95+
96+
```arduino
97+
int rssi = LoRa.packetRSSI();
98+
```
99+
100+
Returns the RSSI of the received packet.
101+
102+
### Available
103+
104+
```arduino
105+
int availableBytes = LoRa.available()
106+
```
107+
108+
Returns number of bytes available for reading.
109+
110+
### Peeking
111+
112+
Peek at the next byte in the packet.
113+
114+
```arduino
115+
byte b = LoRa.peek();
116+
```
117+
118+
Returns the next byte in the packet or `-1` if no bytes available.
119+
120+
### Reading
121+
122+
Read the next byte from the packet.
123+
124+
```arduino
125+
byte b = LoRa.read();
126+
```
127+
128+
Returns the next byte in the packet or `-1` if no bytes available.
129+
130+
**Note:** Other Arduino [`Stream` API's](https://www.arduino.cc/en/Reference/Stream) can also be used to read data from the packet
131+

README.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,54 @@
1-
# arduino-LoRa
2-
An Arduino library for sending and receiving data using LoRa radios.
1+
# Arduino LoRa
2+
3+
An [Arduino](http://arduino.cc/) library for sending and receiving data using [LoRa](https://www.lora-alliance.org/) radios.
4+
5+
## Compatible Hardware
6+
7+
* [Semtech SX1276/77/78/79](http://www.semtech.com/apps/product.php?pn=SX1276) based boards including:
8+
* [Dragino Lora Shield](http://www.dragino.com/products/module/item/102-lora-shield.html)
9+
* [HopeRF](http://www.hoperf.com/rf_transceiver/lora/) [RFM95W](http://www.hoperf.com/rf_transceiver/lora/RFM95W.html), [RFM96W](http://www.hoperf.com/rf_transceiver/lora/RFM96W.html), and [RFM98W](http://www.hoperf.com/rf_transceiver/lora/RFM98W.html)
10+
* [Modtronix](http://modtronix.com/) [inAir4](http://modtronix.com/inair4.html), [inAir9](http://modtronix.com/inair9.html), and [inAir9B](http://modtronix.com/inair9b.html)
11+
* [NiceRF LoRa1276](http://www.nicerf.com/product_view.aspx?id=99)
12+
13+
### Semtech SX1276/77/78/79 wiring
14+
15+
| Semtech SX1276/77/78/79 | Arduino |
16+
| :---------------------: | :------:|
17+
| VCC | 3.3V |
18+
| GND | GND |
19+
| SCK | SCK |
20+
| MISO | MISO |
21+
| MOSI | MOSI |
22+
| NSS | 10 |
23+
| NRESET | 9 |
24+
25+
26+
`NSS` and `NRESET` pins can be changed by using `LoRa.setPins(ss, reset)`.
27+
28+
## Installation
29+
30+
### Using the Arduino IDE Library Manager
31+
32+
1. Choose `Sketch` -> `Include Library` -> `Manage Libraries...`
33+
2. Type `LoRa` into the search box.
34+
3. Click the row to select the library.
35+
4. Click the `Install` button to install the library.
36+
37+
### Using Git
38+
39+
```sh
40+
cd ~/Documents/Arduino/libraries/
41+
git clone https://github.com/sandeepmistry/arduino-LoRa LoRa
42+
```
43+
44+
## API
45+
46+
See [API.md](API.md).
47+
48+
## Examples
49+
50+
See [examples](examples) folder.
51+
52+
## License
53+
54+
This libary is [licensed](LICENSE) under the [MIT Licence](http://en.wikipedia.org/wiki/MIT_License).

0 commit comments

Comments
 (0)