RF69
RF69 library for Arduino
END OF LIFE NOTICE

This RF69 library has now been superceded by the RadioHead library http://www.airspayce.com/mikem/arduino/RadioHead RadioHead and its RH_RF69 driver provides all the features supported by RF69, and much more besides, including Reliable Datagrams, Addressing, Routing and Meshes. All the platforms that RF69 supported are also supported by RadioHead.

This library will no longer be maintained or updated, but we will continue to publish it for the benefit of the the community, and you may continue to use it within the terms of the license. Nevertheless we recommend upgrading to RadioHead where possible.

This is the Arduino RF69 library. It provides an object-oriented interface for sending and receiving data messages with Hope-RF RF69B based radio modules, such as the RFM69 module, (as used on the excellent Moteino and Moteino-USB boards from LowPowerLab http://lowpowerlab.com/moteino/ ) and compatible chips and modules such as RFM69W, RFM69HW, RFM69CW, RFM69HCW (Semtech SX1231, SX1231H) The RFM69 device is described in http://www.hoperf.cn/upload/rf/RFM69-V1.3.pdf and http://www.hoperf.com/upload/rfchip/RF69-V1.2.pdf

The Hope-RF (http://www.hoperf.com) RF69 is a low-cost ISM transceiver chip. It supports FSK, GFSK, OOK over a wide range of frequencies and programmable data rates. It also suports AES encryption of up to 64 octets of payload It is available prepackaged on modules such as the RFM69W. And such modules can be prepacked on processor boards such as the Moteino from LowPowerLabs (which is what we used to develop the RF69 library)

This library provides functions for sending and receiving messages of up to 60 octets on any frequency supported by the RF69, in a range of predefined data rates and frequency deviations. Frequency can be set with 61Hz precision to any frequency from 240.0MHz to 960.0MHz.

Up to 2 RF69B modules can be connected to an Arduino (3 on a Mega), permitting the construction of translators and frequency changers, etc.

This library provides classes for

Coming soon: classes for datagrams, reliable datagrams, routers and meshes

The following modulation types are suppported with a range of modem configurations for common data rates and frequency deviations:

Support for other RF69 features such as on-chip temperature measurement, transmitter power control etc is also provided.

The latest version of this documentation can be downloaded from http://www.airspayce.com/mikem/arduino/RF69

Example Arduino programs are included to show the main modes of use.

The version of the package that this documentation refers to can be downloaded from http://www.airspayce.com/mikem/arduino/RF69/RF69-1.3.zip You can find the latest version at http://www.airspayce.com/mikem/arduino/RF69

Tested on USB-Moteino with arduino-1.0.5 on OpenSuSE 13.1

Packet Format

All messages sent and received by this RF69 library must conform to this packet format:

For technical reasons, the message format is not compatible with the 'HopeRF Radio Transceiver Message Library for Arduino' http://www.airspayce.com/mikem/arduino/HopeRF from the same author. Nor is it compatible with messages sent by 'Virtual Wire' http://www.airspayce.com/mikem/arduino/VirtualWire.pdf also from the same author. Nor is it compatible with messages sent by 'RF22' http://www.airspayce.com/mikem/arduino/RF22 also from the same author.

Connecting RFM-69 to Arduino

We tested with Moteino, which is an Arduino Uno compatible with the RFM69W module on-board. Therefore it needs no connections other than the USB programming connection and an antenna to make it work.

If you have a bare RFM69W that you want to connect to an Arduino, you might use these connections (untested): CAUTION: you must use a 3.3V type Arduino, otherwise you will also need voltage level shifters between the Arduino and the RFM69. CAUTION, you must also ensure you connect an antenna

* Arduino RFM69W
* GND----------GND (ground in)
* 3V3----------3.3V (3.3V in)
* interrupt 0 pin D2-----------DIO0 (interrupt request out)
* SS pin D10----------NSS (chip select in)
* SCK pin D13----------SCK (SPI clock in)
* MOSI pin D11----------MOSI (SPI Data in)
* MISO pin D12----------MISO (SPI Data out)
*

With these connections, you can then use the default constructor RF69(). You can override the default settings for the SS pin and the interrupt in the RF69 constructor if you wish to connect the slave select SS to other than the normal one for your Arduino (D10 for Diecimila, Uno etc and D53 for Mega) or the interrupt request to other than pin D2 (Caution, different processors have different constraints as to the pins available for interrupts).

It is possible to have 2 or more radios connected to one Arduino, provided each radio has its own SS and interrupt line (SCK, SDI and SDO are common to all radios)

Caution: on some Arduinos such as the Mega 2560, if you set the slave select pin to be other than the usual SS pin (D53 on Mega 2560), you may need to set the usual SS pin to be an output to force the Arduino into SPI master mode.

Caution: Power supply requirements of the RF69 module may be relevant in some circumstances: RF69 modules are capable of pulling 45mA+ at full power, where Arduino's 3.3V line can give 50mA. You may need to make provision for alternate power supply for the RF69, especially if you wish to use full transmit power, and/or you have other shields demanding power. Inadequate power for the RF69 is likely to cause symptoms such as: -reset's/bootups terminate with "init failed" messages -random termination of communication after 5-30 packets sent/received -"fake ok" state, where initialization passes fluently, but communication doesn't happen -shields hang Arduino boards, especially during the flashing

Interrupts

The RF69 library uses interrupts to react to events in the RF69 module, such as the reception of a new packet, or the completion of transmission of a packet. The RF69 library interrupt service routine reads status from and writes data to the the RF69 module via the SPI interface. It is very important therefore, that if you are using the RF69 library with another SPI based deviced, that you disable interrupts while you transfer data to and from that other device. Use cli() to disable interrupts and sei() to reenable them.

Memory

The RF69 library requires non-trivial amounts of memory. The sample programs above all compile to about 8kbytes each, which will fit in the flash proram memory of most Arduinos. However, the RAM requirements are more critical. Therefore, you should be vary sparing with RAM use in programs that use the RF69 library.

It is often hard to accurately identify when you are hitting RAM limits on Arduino. The symptoms can include:

Automatic Frequency Control (AFC)

The RF69 module is configured by the RF69 library to always use AFC.

Performance

Some simple speed performance tests have been conducted. In general packet transmission rate will be limited by the modulation scheme. Also, if your code does any slow operations like Serial printing it will also limit performance. We disabled any printing in the tests below. We tested with RF69::GFSK_Rb250Fd250, which is probably the fastest scheme available. We tested with a 13 octet message length, over a very short distance of 10cm.

Transmission (no reply) tests with modulation RF69::GFSK_Rb250Fd250 and a 13 octet message show about 152 messages per second transmitted and received.

Transmit-and-wait-for-a-reply tests with modulation RF69::GFSK_Rb250Fd250 and a 13 octet message (send and receive) show about 68 round trips per second.

Installation

Install in the usual way: unzip the distribution zip file to the libraries sub-folder of your sketchbook.

This software is Copyright (C) 2011 Mike McCauley. Use is subject to license conditions. The main licensing options available are GPL V2 or Commercial:

Donations

This library is offered under a free GPL license for those who want to use it that way. We try hard to keep it up to date, fix bugs and to provide free support. If this library has helped you save time or money, please consider donating at http://www.airspayce.com or here:

Open Source Licensing GPL V2

This is the appropriate option if you want to share the source code of your application with everyone you distribute it to, and you also want to give them the right to share who uses it. If you wish to use this software under Open Source Licensing, you must contribute all your source code to the open source community in accordance with the GPL Version 2 when your application is distributed. See http://www.gnu.org/copyleft/gpl.html

Commercial Licensing

This is the appropriate option if you are creating proprietary applications and you are not prepared to distribute and share the source code of your application. Contact info@.nosp@m.airs.nosp@m.payce.nosp@m..com for details.

Revision History
Version
1.0 Initial release
1.1 Fixed some typos with assistance of shorted neuron.
1.2 Example programs were omitted
1.3 Added End Of Life notice. This library will no longer be maintained and updated: use RadioHead instead.
Author
Mike McCauley (mikem.nosp@m.@air.nosp@m.spayc.nosp@m.e.co.nosp@m.m)