SX1276/77/78/79 LoRa Modules
The Semtech SX1276/77/78/79 or HopeRF RFM95W/96W/98W transceivers feature the LoRa® long range modem that provides ultra-long range spread spectrum communication.
Espruino's SX127x (About Modules) module handles this, however it is extremely beta. Please feed back any issues on GitHub or the Forum.
Wiring
On the inAIR9 from Modtronix you'll want to solder up jumper J4, which applies power to the RF switch.
Connect the rest of the wires as follows
SX1276 | Espruino |
---|---|
GND / 0V | GND |
3V3 | 3.3v |
CK/CLK/SCK | B3 |
SO/MISO | B4 |
SI/MOSI | B5 |
CS/NSS | B6 |
RST/NRESET/RT | B7 |
Software
You set the SX127x
module up like many others:
SPI1.setup({ sck:B3, miso:B4, mosi:B5 });
var sx = require("SX127x").connect({spi: SPI1, cs: B6, rst : B7, callback:function() {
// callback when SX127x is initialised
// Until DIO0 line irqs are implemented we need this:
setInterval(function() { sx.onIRQ(); }, 100);
} });
Note: require("SX127x").connect
doesn't complete immediately, so it is important that you
only use the returned module either >10ms after calling it, or ideally when the callback
function is called.
You should then define some options. Sensible defaults are set, so realistically you need only:
var config = {
rxContinuous : true
};
However all options are shown below:
var config = {
power : 14, // transmit power in dBm, allowed range: -4 to +17dBm or 20dBm. If you use Hope RF or TTGO module see the note below!
freq: 868000000 // frequency in MHz, by default 868MHz
bandwidth : 0 // 0: 125 kHz (default), 1: 250 kHz, 2: 500 kHz
datarate : 7 // spreading factor, 7(default)..12
coderate : 1 // [1: 4/5 (default), 2: 4/6, 3: 4/7, 4: 4/8]
preambleLen : int // peramble length, default: 8
fixLen : bool // fixed length? a boolean. If true, payloadLen needs specifying too
crcOn : bool // CRC enabled?
freqHopOn : bool // frequency hopping on? If true, hopPeriod should be set
iqInverted : bool // Inverts IQ signals
rxContinuous : bool // continuous reception? it's easiest to set this to true and manually cancel reception
symbTimeout : int // RxSingle timeout value when rxContinuous = false
forcePaBoost : bool // Required for HopeRF RFM9xW and TTGO LoRa32 modules
};
Then, to receive, do something like:
sx.setRxConfig(config);
// enter receive mode
sx.rx(function(err, inf) {
// Error, or you get signal strength and data returned in an object
if (err) console.log("RX ERROR");
else console.log("RX>",inf);
});
// after a while, stop receiving
setTimeout(function() {
sx.standby();
}, 10000);
And to transmit, you can do:
sx.setTxConfig(config);
sx.send("Hello", function() {
console.log("TX done");
});
Note about Hope RF RFM95W and TTGO LoRa32 modules and transmit power
To transmit with these modules you have to pass forcePaBoost: true
in the TX configuration.
The manufacturer didn't connect the low-power "RFO" pins to the antenna output. Therefore the lowest output power available with these modules is +2dBm. If the power is outside the allowed range, the library throws SX127x-PA_BOOST_PWR_ERR
.
Reference
SX.prototype.w = function (a, v) { ... }
SX.prototype.r = function (a, s) { ... }
SX.prototype.mask = function (a, mask, v) { ... }
SX.prototype.setOpMode = function (v) { ... }
SX.prototype.init = function () { ... }
SX.prototype.rx = function (callback) { ... }
SX.prototype.tx = function () { ... }
SX.prototype.sleep = function () { ... }
SX.prototype.standby = function () { ... }
SX.prototype.send = function (data, callback) { ... }
SX.prototype.getStatus = function () { ... }
SX.prototype.onIRQ = function () { ... }
SX.prototype.commonSetConfig = function (options) { ... }
SX.prototype.setRxConfig = function (options) { ... }
SX.prototype.setTxConfig = function (options) { ... }
exports.connect = function (options) { ... }
Using
(No tutorials are available yet)
Buying
The SX1276 is available in a variety of different modules, from different places:
- inAIR9 from Modtronix
- eBay SX1276 - watch out for 'compatible' boards that are not true SX1276!
- eBay RFM95W
- eBay TTGO LoRa32
This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.