RN2483/RN2483A LoRa Modules
The RN2483/RN2483A is a fully-certified 433/868 MHz module based on wireless LoRa technology. The module's embedded LoRaWAN Class A protocol allows you connect to LoRaWAN compliant network infrastructure
There's a great tutorial on using the RN2483 module with The Things Network here
Wiring Up
All you need to connect is power, ground, RX and TX pins (to UART-capable pins on your Espruino), and optionally the Reset pin.
If you're using this breakout board then you can place it in breadboard alongside an Espruino Pico or WiFi, making sure it connects as follows:
RN2483 Pin | Espruino connection |
---|---|
GND | GND |
3V3 | 3.3v |
RST | B3 (Optional) |
RX | B6 (Serial1 TX) |
TX | B7 (Serial1 RX) |
Software
Get started by initialising the RN2483
module with Serial at 57600 baud
on the correct pins:
var RN2483 = require("RN2483");
Serial1.setup(57600, { tx:B6, rx:B7 });
var lora = new RN2483(Serial1, {reset:B3});
Note: If attempting to debug you can use {debug:true}
in the options,
eg: var lora = new RN2483(Serial1, {reset:B3, debug:true});
Stand-alone Radio
Once the radio has been set up as above, you can set the RN2483 up to listen on Non-LoRaWAN radio for a certain period of time:
lora.radioRX(10000 /* 10000ms = 10 seconds */, function(data) {
if (data === undefined) {
console.log("No data received");
} else {
console.log("Got data: "+JSON.stringify(data));
}
});
You can then transmit on another module:
lora.radioTX("Hello World!", function() {
console.log("Data sent");
});
And the callback on the first module will be called with the data. radioTX
and
radioRX
automatically pack and unpack the data they are sent, so you can
send a String or Uint8Array containing binary data if you require. (although
radioRX
will always return data as a string).
LoRaWAN
If you need a LoRaWAN server that's relatively lightweight and easy to install on something like a Raspberry Pi, you could use lorawan-server by Petr Gotthard.
Once the RN2483 is set up (see above), you need to connect to a LoRa gateway:
lora.LoRaWAN(
"01234567", // device address
"0123456789ABCDEF0123456789ABCDEF", // nwkSKey
"0123456789ABCDEF0123456789ABCDEF", // appSKey
function(err) {
if (!err) throw Error(err);
});
You can transmit with:
lora.loraTX("my_string_of_data", function(err) {
if (!err) throw Error(err);
});
And can receive data by handling the message
event:
lora.on('message', function(d) {
console.log("RECEIVED",JSON.stringify(d));
});
You only need to call the above code once - it'll be executed whenever a message is received.
Note: LoRa Class A devices only receive data within a short window right after transmitting, so you'll want to ensure that you transmit every minute or so in order to receive data in a timely manner.
Reference
// Reset, either via the reset line if defined, or by a serial command
RN2483.prototype.reset = function (callback) { ... }
// Call the callback with the RN2483's firmware version
RN2483.prototype.getVersion = function (callback) { ... }
/* Call the callback with the current status as an object.
Includes: EUI, VDD, appEUI, devEUI, band, dataRate, rxDelay1 and rxDelay2
*/
RN2483.prototype.getStatus = function (callback) { ... }
/* configure the LoRaWAN parameters
devAddr = 4 byte address for this device as hex - eg. "01234567"
nwkSKey = 16 byte network session key as hex - eg. "01234567012345670123456701234567"
appSKey = 16 byte application session key as hex - eg. "01234567012345670123456701234567"
*/
RN2483.prototype.LoRaWAN = function (devAddr, nwkSKey, appSKey, callback) { ... }
// Set whether the MAC (LoRaWan) is enabled or disabled
RN2483.prototype.setMAC = function (on, callback) { ... }
// Transmit a message over the radio (not using LoRaWAN)
RN2483.prototype.radioTX = function (msg, callback) { ... }
/* Transmit a message (using LoRaWAN). Will call the callback with 'null'
on success, or the error message on failure.
In LoRa, messages are received right after data is transmitted - if
a message was received, the 'message' event will be fired, which
can be received if you added a handler as follows:
lora.on('message', function(data) { ... });
*/
RN2483.prototype.loraTX = function (msg, callback) { ... }
/* Receive a message from the radio (not using LoRaWAN) with the given timeout
in miliseconds. If the timeout is reached, callback will be called with 'undefined'
*/
RN2483.prototype.radioRX = function (timeout, callback) { ... }
/* Connect to a RN2483.
First argument is the serial device, second is an
object containing:
{
reset : pin // optional
debug : true // optional
}
*/
function (serial, options) { ... }
Buying
You can get the modules themselves from normal elecronics distributors like
Farnell, Mouser or RS. Just search for RN2483A
(the RN2483
has been replaced
with the updated but compatible RN2483A
).
However you'll need a breakout board. You can buy one from DrAzzy on Tindie that will break out the connections in a form that will connect directly to the edge of the Espruino Pico or WiFi boards.
This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.