All of the tinkering so far is nice, but let’s raise the stakes a bit and create a little setup to test all this, so we can end up with this funny geeky gadget called the RF Node Watcher:
That’s the main µC board, an RFM69 radio for the 868 MHz ISM band (connected over SPI), a push button, and a fun little 128×64 OLED graphics display (connected over I2C).
The back side has a bit of wiring soldered on to connect it all together:
Here’s a demo of the OLED in action (full code in the Embello repository on GitHub):
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled;
static const uint8_t logo_64x64[] = { ... };
void setup() {
// generate OLED supply internally from 3.3V
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
oled.clearDisplay();
oled.drawBitmap(32, 00, logo_64x64, 64, 64, 1);
oled.display();
}
void loop() {}
As you can see, it uses an existing library to drive the OLED. Here is the result:
Running a little demo for the RFM69 wireless radio is deceptively simple, because most of the hard work has already been done, and this code was simply ported from the LPC8xx:
#include <SPI.h>
#include "spi.h"
#include "rf69.h"
RF69<SpiDev> rf;
void setup () {
Serial.begin(115200);
Serial.println("[radio]");
rf.init(1, 42, 8686);
}
void loop () {
uint8_t buffer [70];
int n = rf.receive(buffer, sizeof buffer);
if (n >= 0) {
Serial.print("got #");
Serial.print(n);
Serial.print(':');
for (int i = 0; i < n; ++i) {
Serial.print(' ');
Serial.print(buffer[i]);
}
Serial.println();
}
}
The output is reported over the USB serial port.
And as final “pièce de résistance” for now, there’s a sketch called watcher, which combines everything into one big demo, using the components on this board. It listens for incoming packets and shows the last four of them in a tiny compact list on that OLED display:
Only useful for geeks who need to “see” all those packets flying through the air, but hey!
[Back to article index]