HopeRF RFM69 Wireless Module
The HopeRF RFM69 is a transceiver module capable of operation over a wide frequency range, including the 315,433, 868 and 915MHz license-free ISM (Industry Scientific and Medical) frequency bands. (datasheet here)
A driver for it is available in the RFM69 (About Modules) module.
Note: This module is still very new, and doesn't support anywhere near all the features of the RFM69. Contributions are always appreciated!
Connect as follows:
RFM69 | Name | Espruino |
---|---|---|
1 | RST | B1 |
2 | DIO0 | |
3 | DIO1 | |
4 | DIO2 | |
5 | DIO3 | |
6 | DIO4 | |
7 | DIO5 | |
8 | 3.3V | 3.3 |
9 | GND | GND |
10 | ANA | Aerial of correct length - around 17.3cm |
11 | GND | GND |
12 | SCK | B13 |
13 | MISO | B14 |
14 | MOSI | B15 |
15 | NSS | B10 |
15 | NC | GND |
For the Espruino Pico, there is an adaptor shim available that makes connecting this module a lot easier.
Software
There are simple functions that allow you to send and receive data:
To send data when the button is pressed:
var rfm;
function onInit() {
SPI2.setup({mosi:B15,miso:B14,sck:B13});
rfm = require("RFM69").connect(SPI2, {cs:B10, rst:B1, freq:434}, function() {
console.log("Connected");
});
}
setWatch(function() {
digitalWrite(LED1,1);
rfm.sendPacket("Hello World", function() {
digitalWrite(LED1,0); // done sending
});
}, BTN, {debounce:50, edge:"rising", repeat:true});
And to repeatedly listen for data:
var rfm;
function onInit() {
SPI2.setup({mosi:B15,miso:B14,sck:B13});
rfm = require("RFM69").connect(SPI2, {cs:B10, rst:B1, freq:434}, function() {
rfm.rxmode(); // in order to receive data
console.log("Connected");
setInterval(function() {
if (rfm.hasPacket())
console.log("Received : "+JSON.stringify(E.toString(rfm.getPacket())));
},100);
});
}
Reference
// Initialise the RFM69 - called automatically by require("RFM69").connect
RFM69.prototype.connect = function (callback) { ... }
// Internal: read register
RFM69.prototype.r = function (a) { ... }
// Internal: write register
RFM69.prototype.w = function (a, v) { ... }
// Internal: write register and value in one
RFM69.prototype.w16 = function (v) { ... }
/* Put the RFM69 into receive mode. After this,
DIO0 should be raised if a packet is ready, however
you can poll with `hasPacket`
*/
RFM69.prototype.rxmode = function () { ... }
// Return true if RFM69 has received a packet, false otherwise
RFM69.prototype.hasPacket = function () { ... }
// Get a packet received by RFM69, as a Uint8Array
RFM69.prototype.getPacket = function () { ... }
// Send a packet, maximum length is 64 bytes
RFM69.prototype.sendPacket = function (d, callback) { ... }
/* Create an RFM69 object using the given SPI bus.
`options` can contain:
cs : chip select pin (required)
rst : reset pin (optional)
freq : frequency - one of 315, 434, 868, 915 (default is 434)
`callback` is optional and is called when the RFM69 has been initialised
*/
exports.connect = function (spi, options, callback) { ... }
Using
(No tutorials are available yet)
This page is auto-generated from GitHub. If you see any mistakes or have suggestions, please let us know.