SX1276/77/78/79 LoRa Modules

The SX1276/77/78/79 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 });

// Until DIO0 line irqs are implemented we need this:
setInterval(function() { sx.onIRQ(); }, 100);

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, // dbM
 bandwidth // 0: 125 kHz, 1: 250 kHz, 2: 500 kHz
 datarate // spreading factor, 7..12  
 coderate // [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
 preambleLen : int // peramble length
 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
};

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");
});

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 use this yet.

Buying

The SX1276 is available in a variety of different modules, from different places:

This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.