{"id":19346635,"url":"https://github.com/cyraxx/node-rfm9x","last_synced_at":"2025-04-23T05:30:48.409Z","repository":{"id":61517897,"uuid":"549683266","full_name":"cyraxx/node-rfm9x","owner":"cyraxx","description":"Node.js module for SPI communication with RFM9x wireless modules (e.g. Adafruit Radio Bonnet)","archived":false,"fork":false,"pushed_at":"2022-11-09T13:58:16.000Z","size":15,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-03T23:19:48.727Z","etag":null,"topics":["adafruit","iot","lora","nodejs","nodejs-modules","raspberry","rfm95","rfm96","rfm97","rfm98","rfm9x","rpi","sx127x","wireless"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cyraxx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-11T15:12:46.000Z","updated_at":"2024-10-08T14:08:58.000Z","dependencies_parsed_at":"2022-10-19T22:30:35.180Z","dependency_job_id":null,"html_url":"https://github.com/cyraxx/node-rfm9x","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyraxx%2Fnode-rfm9x","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyraxx%2Fnode-rfm9x/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyraxx%2Fnode-rfm9x/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyraxx%2Fnode-rfm9x/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cyraxx","download_url":"https://codeload.github.com/cyraxx/node-rfm9x/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223909967,"owners_count":17223592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adafruit","iot","lora","nodejs","nodejs-modules","raspberry","rfm95","rfm96","rfm97","rfm98","rfm9x","rpi","sx127x","wireless"],"created_at":"2024-11-10T04:11:22.961Z","updated_at":"2024-11-10T04:11:23.363Z","avatar_url":"https://github.com/cyraxx.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\n\nNode.js module to interface with RFM9x LoRa wireless modules. Intended for use\nwith [Adafruit Radio Bonnets](https://learn.adafruit.com/adafruit-radio-bonnets/overview).\n\nThe code has only been tested on Raspberry Pi but could technically also work\non other boards supported by onoff and spi-device.\n\n## Acknowledgements\n\n- The [CircuitPython RFM9x module](https://github.com/adafruit/Adafruit_CircuitPython_RFM9x)\nwas used as a template for most of the logic.\n- The [spi-device](https://github.com/fivdi/spi-device) and [onoff](https://github.com/fivdi/onoff)\nmodules by fivdi made interfacing with the hardware really easy.\n\n# Example\n\nSee `example/pingpong.js` for a simple example of receiving and sending data.\n\n# API\n\nThe modules exports a single class `RFM9x`.\n\n## Class `RFM9x`\n\nClass representing the LoRa module. The constructor requires no arguments.\n\n```js\nconst rfm9x = require('rfm9x');\nconst module = new rfm9x();\n\nawait module.init({ ... });\n```\n\n---\n\n### Properties\n\n* [`debug`](#debug) - Output SPI debug information\n\n#### `debug`\n\nSet this property to `true` to get all SPI communication printed out to the console.\n\n**Note:** Because `console.log()` calls are synchronous in most circumstances, enabling this can impact\ntiming! For example, it might cause switching from sending to receiving mode to be slow enough to miss\nresponses from other nodes.\n\n---\n\n### Methods\n\n* [`init(options)`](#initoptions) - Initialize module and LoRa settings\n* [`startReceive()`](#startreceive) - Put the LoRa module in receive mode and enable the `receive` event\n* [`stopReceive()`](#stopreceive) - Put the LoRa module in standby mode and stop receiving packets\n* [`send(payload)`](#sendpayload) - Send a packet via LoRa\n* [`getVersion()`](#getversion) - Get the chip version number from the module\n\n#### `init(options)`\n\n- `options` - Options object (see below). All properties are optional, default values will be\nused when omitted.\n\nInitialize module and LoRa settings. Needs to be called before using any of the radio functions.\n\nReturns a Promise that resolves with no value.\n\nThe following options are supported:\n\n- `frequencyMhz` - Base frequency in MHz, default: `915`\n- `preambleLength` - LoRa preamble length in bytes, default: `8`\n- `bandwidthHz` - LoRa bandwidth in Hz, default: `500000`\n- `codingRate` - LoRa coding rate, valid values are `5` (4/5) to `8` (4/8), default: `5`\n- `spreadingFactor` - LoRa spreading factor, valid values are `6` to `12`, default: `7`\n- `enableCrcChecking` - Whether to enable CRC checking on incoming packets, default: `false`\n- `txPowerDb` - Transmitter power in dB, valid values are `5` to `23` (currently only high power mode is\nsupported), default: `23`\n- `enableAgc` - Whether to enable Automatic Gain Control, default: `false`\n- `resetPin` - Number of the GPIO pin that the RFM9x RESET line is connected to, default: `25`\n- `dio0Pin` - Number of the GPIO pin that the RFM9x DIO0 line is connected to, default: `22`\n- `dio1Pin` - *Not currently used.* Number of the GPIO pin that the RFM9x DIO1 line is connected to,\ndefault: `23`\n- `dio2Pin` - *Not currently used.* Number of the GPIO pin that the RFM9x DIO2 line is connected to,\ndefault: `24`\n- `spiSpeedHz` - Speed of the SPI communication in Hz, default: `100000`\n- `txTimeoutMs` - Maximum time in milliseconds to wait for a packet transmission to finish, default: `2000`\n\n#### `startReceive()`\n\nPut the LoRa module in receive mode and enable the `receive` event.\n\nReturns a Promise that resolves with no value.\n\n#### `stopReceive()`\n\nPut the LoRa module in standby mode and stop receiving packets.\n\nReturns a Promise that resolves with no value.\n\n#### `send(payload)`\n\n- `payload` - A `Buffer` of up to 255 bytes\n\nSend a packet via LoRa.\n\nReturns a Promise that resolves with no value after the transmission is finished.\n\n**Note:** After transmitting a packet, the module switches into standby mode automatically. If you want to\ncontinue receiving packets after a transmission, you will need to call `startReceive()` after the transmission\ncompleted.\n\n#### `getVersion()`\n\nGet the chip version number from the module.\n\nReturns a Promise that resolves with the version number (one-byte integer).\n\n---\n\n### Events\n\n* [`receive(packet)`](#receivepacket) - Emitted when a LoRa packet has been received\n* [`receiveError()`](#receiveerror) - Emitted when an invalid LoRa packet has been received\n\n#### `receive(packet)`\n\nEvent that is emitted when a LoRa packet is received.\n\n`packet` is an object containing the following properties:\n- `payload` - A `Buffer` containing the packet contents\n- `rssiDb` - RSSI of the packet in dB\n- `snrDb` - SNR of the packet in dB\n\n#### `receiveError()`\n\nEvent that is emitted when a LoRa packet is received but was discarded due to receive errors (e.g. CRC check\nfailed).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyraxx%2Fnode-rfm9x","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyraxx%2Fnode-rfm9x","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyraxx%2Fnode-rfm9x/lists"}