RFM69HCW Hookup Guide

Pages
Contributors: MikeGrusin
Favorited Favorite 8

How it Works

"How does... how does it work?"
"I know not, my Liege"
"Consult the Book of Armaments!"
      -Monty Python and the Holy Grail

The information below will help you better understand how your RFM69HCW module works, which will help you use it more effectively in your projects. However, if you're itching to start using it right away, you can jump straight to Running the Example Code.

Packets

To save power and let multiple modules share the same frequency, the RFM69HCW doesn't transmit continuously. Instead, it sends short bursts of data called packets. You can think of these as short messages sent from one RFM69 to another.

Packets can be sent very quickly and repeatedly, giving the illusion of a continuous connection. And, because the transmitter is on only for the fraction of a second it takes to transmit each packet, many modules can share the same frequency.

Each packet can contain up to 61 bytes of data. This is the actual message that you're sending from one node to another. This data can be text characters or binary numbers; as far as the RFM69 is concerned, it's just a block of data. If you need to send more than 61 bytes, just send more packets.

The format of the message (what it contains) is entirely up to you. Normally you'll come up with a format for your specific application (e.g. "three decimal numbers separated by spaces"), and write your code so that both the sender and receiver expect the same format.

Addressing

In order for a message to get from one RFM69 to another, each module (often called a node) must be given its own address. Addresses consist of two numbers: the network number, which is like the town in which all the nodes live, and the node number which is like an individual street address. Each of these numbers can range from 0 to 255.

You get to (and must!) choose these numbers. Even if you just have two nodes, you'll need to give them address numbers in your code. The address is set by your code each time the RFM69HCW is powered up; it doesn't remember the address when it is powered off.

Network Number

The network number should be the same for all the RFM69HCWs that you want talking to each other. Each network will be isolated from all the others - modules in network 0 won't be affected by anything going on in network 1, etc. You can have up to 256 networks operating in the same area, numbered 0 to 255.

Node Number

The node number should be different for all your RFM69HCWs (on the same network). These are the individual addresses that are used to e.g. send a message from node 2 to node 3. You can have up to 255 nodes in a network, numbered 0 to 254.

Broadcast Address

Sharp-eyed readers may have noticed that node addresses only go to 254, not 255. That's because 255 is a special "broadcast" address; if you send a message to address 255, all of the nodes on that network will receive it.

"Promiscuous Mode"

Apart from the broadcast address, messages sent between nodes are usually "private." Nodes will normally ignore messages that aren't addressed to them.

However, you can turn on something called “promiscuous mode,” which tells the node to receive every message that it hears on the network. This can be useful for debugging, routing messages to and from the radio network, etc, but note that even promiscuous mode won’t let you hear messages sent on a different network.

Acknowledgement

When you send a message, you have the choice of sending it "in the blind," hoping that the receiver will pick it up, or you can request an acknowledgement (usually shortened to "ACK") that the message was received. In fact, the RFM69 library can automatically resend a message until it either receives an acknowledgement from the receiver (success!) or it has resent it a specific number of times without a response (fail).

Whether you use acknowledgements or not depends on your application. You may want to use acknowlegements if the data you're sending is very important or if you want to be sure that both ends of a link are functional. But, some applications work better in the blind, such as high-bandwidth data where a lost message isn't a big deal, beacons that multiple modules may receive, one-way links using highly-directional antennas, etc. It's up to you.

There's one catch: even though it's easy to request an acknowledgement when you send a message, the receiver will not automatically send an acknowlegement. Your code must check received messages for acknowledgement requests and send acknowledge messages manually. See the example code for details.

Encryption

As noted above, "promiscuous mode" will let you silently listen in on all the conversations going on in a given network. If you're sending sensitive information, this may not be good news to you since someone else may be listening to your conversations. Fortunately, the RFM69 can protect your communications using AES (Advanced Encryption Standard) encryption, which is extremely secure.

Encryption can be turned on or off by a library command (see the examples for details). You'll also need to make sure that both ends of your link are using the same 16-byte key. Only those RFM69s using exactly the same key will be able to decode the messages.

PROTIP: Similarly, anyone who *has* the key will be able to decode your messages, so be sure to keep the key secret! In particular, remember that it will be saved along with your source code, so erase the key before saving it, or keep your source code secret as well.