REYAX RYLR896/406/895/405 LoRa modules

RYLR896

REYAX RYLR896/406/895/405 LoRa modules provide LoRa connectivity with an AT-command Serial interface to the host microcontroller. The RYLR (About Modules) module provides a simple JavaScript interface for those modules.

Wiring

Just wire up:

  • The power supply to 3.3v
  • RX and TX wires to Serial-capable pins on your Espruino device

Software

/*
This is an example of using Espruino JS to control a REYAX LoRa module.
It listens for "on" and "off" messages to change and LED and
sends "on" and "off" messages by pressing the button.
*/
var RYLR = require('RYLR');

Serial1.setup(115200, {rx: B7, tx: B6});
var lora = RYLR.connect(Serial1);

lora.setNetwork(13).then(res => {
  return lora.setAddress(1);
}).then(res => {
  lora.on('data', evt => {
    digitalWrite(LED1, evt.data == 'on');
  });
});

setWatch(evt => {
  lora.send(evt.state ? 'on' : 'off', 2);
}, BTN, {repeat: true, edge: 'both'});

Reference

// Construct an RYLR instance from a USART interface.
RYLR.prototype.constructor = function (usart) { ... }

// Wraps at.cmd with Promise and basic response handling.
RYLR.prototype.atcmd = function (cmd, timeout) { ... }

// Handle "+RCV=" events (incoming messages).
RYLR.prototype._receive = function (line) { ... }

// Perform a software reset.
RYLR.prototype.reset = function () { ... }

// Set sleep mode (0=normal, 1=sleep).
RYLR.prototype.setMode = function (mode) { ... }

// Get sleep mode.
RYLR.prototype.getMode = function () { ... }

// Set UART baud rate.
RYLR.prototype.setBaudRate = function (baud) { ... }

// Get UART baud rate.
RYLR.prototype.getBaudRate = function () { ... }

/* Set device parameters.
    spreadingFactor is the RF spreading factor.
    Valid range between 7-12 (inclusive).
    Default is 12.
    bandwidth specifies the RF bandwidth and it should be a number between 0-9
    that corresponds to the following table:
      0: 7.8KHz (not recommended, over spec.)
      1: 10.4KHz (not recommended, over spec.)
      2: 15.6KHz
      3: 20.8 KHz
      4: 31.25 KHz
      5: 41.7 KHz
      6: 62.5 KHz
      7: 125 KHz (default)
      8: 250 KHz
      9: 500 KHz
    codingRate is the LoRa forward error correction coding rate.
    Valid range between 1-4 (inclusive).
    Defaults to 1.
    preamble is the LoRa programmed preamble. Valid range between 4-7.
    Defaults to 4.
*/
RYLR.prototype.setParameter = function (options) { ... }

// Get device parameters.
RYLR.prototype.getParameter = function () { ... }

// Set RF frequency band (in Hz).
RYLR.prototype.setBand = function (band) { ... }

// Get RF frequency band (in Hz).
RYLR.prototype.getBand = function () { ... }

// Set device address. Valid range between 0-65535 (inclusive).
RYLR.prototype.setAddress = function (address) { ... }

// Get device address.
RYLR.prototype.getAddress = function () { ... }

// Set network ID. Valid range between 0-16 (inclusive).
RYLR.prototype.setNetwork = function (networkID) { ... }

// Get network ID.
RYLR.prototype.getNetwork = function () { ... }

/* Set password for communication. This is a 32 character long hex string that
    represents the 16 byte AES key used for encryption. Both LoRa modules need to
    use the same password in order to communicate.
*/
RYLR.prototype.setPassword = function (password) { ... }

// Get password.
RYLR.prototype.getPassword = function () { ... }

// Set RF power level in dBm. Valid range between 0 and 15 (inclusive).
RYLR.prototype.setPower = function (power) { ... }

// Get RF power level in dBm.
RYLR.prototype.getPower = function () { ... }

// Send data to optional address (defaults to 0).
RYLR.prototype.send = function (data, address) { ... }

// Get firmware version.
RYLR.prototype.getVersion = function () { ... }

// Reset device configuration to factory defaults.
RYLR.prototype.setFactory = function () { ... }

// Return a new RYLR LoRa connection object from a USART interface.
exports.connect = function (usart) { ... }

Buying

You can get REYAX RYLR modules from eBay - just ensure that you get a module advertised as supporting the AT command interface (some of them are bare SX127x modules).

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