mirror of
https://github.com/sandeepmistry/arduino-LoRa.git
synced 2025-04-19 13:02:14 +03:00
Add initial documentation
This commit is contained in:
parent
1fb8b29f62
commit
d690d7947f
131
API.md
Normal file
131
API.md
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
# LoRa API
|
||||||
|
|
||||||
|
## Include Library
|
||||||
|
|
||||||
|
```arduino
|
||||||
|
#include <LoRa.h>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
### Begin
|
||||||
|
|
||||||
|
Initialize the library with the specified frequency.
|
||||||
|
|
||||||
|
```arduino
|
||||||
|
LoRa.begin(frequency);
|
||||||
|
```
|
||||||
|
* `frequency` - frequency in Hz (`433E6`, `866E6`, `915E6`)
|
||||||
|
|
||||||
|
Returns `1` on success, `0` on failure.
|
||||||
|
|
||||||
|
## Set pins
|
||||||
|
|
||||||
|
Override the default `NSS` and `NRESET` pins used by the library. **Must** be called before `LoRa.begin()`.
|
||||||
|
|
||||||
|
```arduino
|
||||||
|
LoRa.setPins(ss, reset);
|
||||||
|
```
|
||||||
|
* `ss` new slave select pin to use, defaults to `10`
|
||||||
|
* `reset` new reset pin to use, defaults to `9`
|
||||||
|
|
||||||
|
### End
|
||||||
|
|
||||||
|
Stop the library
|
||||||
|
|
||||||
|
```arduino
|
||||||
|
LoRa.end()
|
||||||
|
```
|
||||||
|
|
||||||
|
## Sending data
|
||||||
|
|
||||||
|
### Begin packet
|
||||||
|
|
||||||
|
Start the sequence of sending a packet.
|
||||||
|
|
||||||
|
```arduino
|
||||||
|
LoRa.beginPacket();
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns `1` on success, `0` on failure.
|
||||||
|
|
||||||
|
### Writing
|
||||||
|
|
||||||
|
Write data to the packet. Each packet can contain up to 255 bytes.
|
||||||
|
|
||||||
|
```arduino
|
||||||
|
LoRa.write(byte);
|
||||||
|
|
||||||
|
LoRa.write(buffer, length);
|
||||||
|
```
|
||||||
|
* `byte` single byte to write to packet
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
* `buffer` data to write to packet
|
||||||
|
* `length` size of data to write
|
||||||
|
|
||||||
|
Returns the number of bytes written.
|
||||||
|
|
||||||
|
**Note:** Other Arduino `Print` API's can also be used to write data into the packet
|
||||||
|
|
||||||
|
### End packet
|
||||||
|
|
||||||
|
End the sequence of sending a packet.
|
||||||
|
|
||||||
|
```arduino
|
||||||
|
LoRa.endPacket()
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns `1` on success, `0` on failure.
|
||||||
|
|
||||||
|
## Receiving data
|
||||||
|
|
||||||
|
### Parsing packet
|
||||||
|
|
||||||
|
Check if a packet has been received.
|
||||||
|
|
||||||
|
```arduino
|
||||||
|
int packetSize = LoRa.parsePacket();
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns the packet size or `0` if no packet was received.
|
||||||
|
|
||||||
|
### Packet RSSI
|
||||||
|
|
||||||
|
```arduino
|
||||||
|
int rssi = LoRa.packetRSSI();
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns the RSSI of the received packet.
|
||||||
|
|
||||||
|
### Available
|
||||||
|
|
||||||
|
```arduino
|
||||||
|
int availableBytes = LoRa.available()
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns number of bytes available for reading.
|
||||||
|
|
||||||
|
### Peeking
|
||||||
|
|
||||||
|
Peek at the next byte in the packet.
|
||||||
|
|
||||||
|
```arduino
|
||||||
|
byte b = LoRa.peek();
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns the next byte in the packet or `-1` if no bytes available.
|
||||||
|
|
||||||
|
### Reading
|
||||||
|
|
||||||
|
Read the next byte from the packet.
|
||||||
|
|
||||||
|
```arduino
|
||||||
|
byte b = LoRa.read();
|
||||||
|
```
|
||||||
|
|
||||||
|
Returns the next byte in the packet or `-1` if no bytes available.
|
||||||
|
|
||||||
|
**Note:** Other Arduino [`Stream` API's](https://www.arduino.cc/en/Reference/Stream) can also be used to read data from the packet
|
||||||
|
|
56
README.md
56
README.md
@ -1,2 +1,54 @@
|
|||||||
# arduino-LoRa
|
# Arduino LoRa
|
||||||
An Arduino library for sending and receiving data using LoRa radios.
|
|
||||||
|
An [Arduino](http://arduino.cc/) library for sending and receiving data using [LoRa](https://www.lora-alliance.org/) radios.
|
||||||
|
|
||||||
|
## Compatible Hardware
|
||||||
|
|
||||||
|
* [Semtech SX1276/77/78/79](http://www.semtech.com/apps/product.php?pn=SX1276) based boards including:
|
||||||
|
* [Dragino Lora Shield](http://www.dragino.com/products/module/item/102-lora-shield.html)
|
||||||
|
* [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)
|
||||||
|
* [Modtronix](http://modtronix.com/) [inAir4](http://modtronix.com/inair4.html), [inAir9](http://modtronix.com/inair9.html), and [inAir9B](http://modtronix.com/inair9b.html)
|
||||||
|
* [NiceRF LoRa1276](http://www.nicerf.com/product_view.aspx?id=99)
|
||||||
|
|
||||||
|
### 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 |
|
||||||
|
|
||||||
|
|
||||||
|
`NSS` and `NRESET` pins can be changed by using `LoRa.setPins(ss, reset)`.
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd ~/Documents/Arduino/libraries/
|
||||||
|
git clone https://github.com/sandeepmistry/arduino-LoRa LoRa
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
See [API.md](API.md).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
See [examples](examples) folder.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This libary is [licensed](LICENSE) under the [MIT Licence](http://en.wikipedia.org/wiki/MIT_License).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user