Computing stuff tied to the physical world

Debugging the RF link

Debugging wireless communications can be tricky, especially if the hardware and the software are both untested. We’re going to have to figure out all the details on the sending as well as the receiving side, and until it all works there will be preciously little feedback.

So the first step is really to simplify. We shouldn’t try to debug the RF sender, RF receiver, both sides of the I2C communication and the Raspberry Pi hookup all at once.

We have a working upload setup for the LPC810, based on FTDI, and we have a working serial connection to print debugging information. So let’s start with this direct hookup:

DSC 4930

That’s a modified USB BUB, an LPC810 upload board (including a 3.3V regulator), with six wires to an RFM69 radio module: two for power, 4 for SPI. And an antenna wire.

The wiring is all white, unfortunately, but this is only a temporary setup for debugging – check out the gpio/pin assignments in the code below if you want to see what goes where.

Here is the listen test code we’ll use:

#include <stdio.h>
#include "serial.h"

#include "spi.h"
#include "rf69.h"

RF69<SpiDevice> rf;
uint8_t rxBuf[66];

int main () {
    LPC_SWM->PINASSIGN0 = 0xFFFFFF04;   // only connect 4p2 (TXD)
    serial.init(LPC_USART0, 115200);

    LPC_SWM->PINENABLE0 |= 3<<2;        // disable SWCLK/SWDIO
    // lpc810 coin: sck=0p8, ssel=3p3, miso=2p4, mosi=1p5
    LPC_SWM->PINASSIGN3 = 0x00FFFFFF;   // sck  -    -    -
    LPC_SWM->PINASSIGN4 = 0xFF030201;   // -    nss  miso mosi

    rf.init(1, 42, 8683);
    while (true) {
        int len = rf.receive(rxBuf, sizeof rxBuf);
        if (len >= 0) {
            printf("OK ");
            for (int i = 0; i < len; ++i)
                printf("%02x", rxBuf[i]);
            printf(" (%d%s%d:%d)\n",
                    rf.rssi, rf.afc < 0 ? "" : "+", rf.afc, rf.lna);

This uses the new RF69 driver to report all incoming packets on the serial port. The node is set up as id 1, group 42, and frequency 868.3 MHz, but feel free to adjust these as needed.

The output from this code will not be terribly exciting at this stage:

$ lpc21isp [...]
Terminal started (press Escape to abort)


And then: silence – because there’s nothing sending out packets yet! Let’s fix that next…

[Back to article index]