Here’s a driver for the RFM12B radio with Arduino’s and similar AVR boards. The radio is connected as follows:
The code is available as RF12.zip or via subversion. It’s packaged as an Arduino library. To try out the included example, you’ll obviously need two Arduino’s + radio modules, connected as above. Then:
- unpack the above zip as new directory in your Arduino IDE’s “libraries/” folder
- build and upload the included example sketch to both systems
- check proper operation by opening the serial port at 57600 baud
- you should see a “[RF12DEMO]” greeting on both
- on one unit, type “0i 0i 1i” to set its node ID to 1
- on the other, type “0i 0i 2i” to set its node ID to 2
- send a test packet of 7x <N> bytes by typing “<N>s” (<N> = 0..9)
- you should see the test packet on the other node
- use “<N>a” to send a test packet and request an ack
The node ID is stored in EEPROM (the demo uses byte 0), so you only need to initialize ID’s once in each node.
This code uses interrupts to do most of the work in the background for transmission as well as reception. The packet buffer is limited to 66 bytes of data. All packets are verified with a 16-bit CRC.
Packets can be sent to a specific node (ID 1..30) or broadcast to all (ID 0). The demo code sends its test packets as broadcasts, but replies with acknowledgements to just the originator. Note that requesting an acknowledgement for broadcast packets only makes sense with two nodes.
Update – instructions for the demo are now slightly different (see the).