npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rfm69radio

v4.0.0

Published

A Node module for sending and receiving through RFM69 radios on the Raspberry Pi.

Downloads

11

Readme

RFM69RADIO

A Node module for sending and receiving through RFM69 radios on the Raspberry Pi.

Ported from etrombly's python version of the LowPowerLab code.

Hardware

This version tested on a pair of Adafruit RFM69HCW Radios with this NodeJS code running on a Raspberry Pi 3 Model B.

The default wiring is:

| RFM pin | Pi pin
| ------- |------- | 3v3 | 17
| DIO0 | 18 (GPIO24)
| MOSI | 19 (GPIO10) | MISO | 21 (GPIO09) | CLK | 23 (GPIO11) | CS (NSS)| 24 (GPIO08 CS0) | Ground | 25
| RESET | 29 (GPIO05)

See here for the Raspberry Pi 3 GPIO pins.

The second radio is connected to an Arduino UNO running the code in frm69_test.ino and connected according to the instrucitons from Adafruit.

Install

npm install rfm69radio

Usage

Create the module.

const RFM69 = require('rfm69radio');
const rfm69 = new RFM69();

Initialize the radio. Provide an address for the node and optionally a 16 char encryption key. Then, register callback to handle recevied packets. Then, read the temperature of the radio ic. Then, calibrate the radio. Then, send some packets.

rfm69.initialize({
  address: 1,
  // encryptionKey: '0123456789abcdef',
  verbose: false,
  powerLevelPercent: 20,
})
  .then(() => {
    console.log('Initialized');
    rfm69.registerPacketReceivedCallback(packetReceivedCallback1);
    rfm69.registerPacketReceivedCallback(packetReceivedCallback2);
    return true;
  })
  .then(() => rfm69.readTemperature())
  .then((temp) => {
    console.log(`Temp: ${temp}`);
    rfm69.calibrateRadio();
    return true;
  })
  .then(() => {
    setInterval(() => {
      const toAddress = 2;
      console.log(`Sending packet to address ${toAddress}`);
      rfm69.send({ toAddress: toAddress, payload: `Hello ${timeStamp()}`, attempts: 3, requireAck: true })
        .then((packet) => {
          console.log(`Sent on attempt ${packet.attempts} after ${packet.ackTimestamp - packet.timestamp}ms`);
          return true;
        })
        .catch(err => console.log(err));
    }, 3000);

    setTimeout(() => {
      rfm69.broadcast('Broadcast!!')
        .then(() => {
          console.log('Sent broadcast');
          return true;
        })
        .catch(err => console.log(err));
    }, 2000);
    return true;
  })
  .catch(err => {
    console.log(`Error initializing radio: ${err}`);
    rfm69.shutdown();
  });


function packetReceivedCallback1(packet) {
  console.log(`Packet received (callback1) from peer ${packet.senderAddress} "${packet.payload}" RSSI:${packet.rssi}`);
}
function packetReceivedCallback2(packet) {
  console.log(`Packet received (callback2) from peer ${packet.senderAddress} "${packet.payload}" RSSI:${packet.rssi}`);
} 

The initialize parameters and their defaults are:

{
        freqBand = 'RF69_915MHZ', // 'RF69_315MHZ' or 'RF69_433MHZ' or 'RF69_868MHZ' or 'RF69_915MHZ' depending on radio hardware
        address = 1, // Address for this node
        networkID = 100,
        isRFM69HW = true, // Is High Power radio? Must be true for RF69HCW, RF69HW
        powerLevelPercent = 70, // Transmit power between 0 and 100
        interruptPin = 24, // Pin number of interrupt pin. This is a GPIO number (GPIO24 = pin 18).
        resetPin = 5, // Pin number of reset pin. This is a GPIO number (GPIO5 = pin 29).
        spiBus = 0, // SPI bus number.
        spiDevice = 0, // SPI device number.
        promiscuousMode = false, // Accept all packets
        encryptionKey = 0, // Key for AES encryption. Must be 16 chars long or no encryption set
        autoAcknowledge = true, // Automatically reply with Ack
        verbose = false, // Verbose logging to console
      }

Dependencies