Skip to content

Instantly share code, notes, and snippets.

@wybiral
Created October 11, 2018 23:38
Show Gist options
  • Save wybiral/09766503172808a1df866fe173abbb41 to your computer and use it in GitHub Desktop.
Save wybiral/09766503172808a1df866fe173abbb41 to your computer and use it in GitHub Desktop.
This is an example of using Espruino JS to control a REYAX LoRa module.
/*
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.
Watch the video here: https://youtu.be/IStuUv9eAmE
*/
const RYLR = require('https://github.com/wybiral/espruino-modules/blob/master/RYLR.js');
Serial1.setup(115200, {rx: B7, tx: B6});
const 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'});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment