Simple RF scanner

spectrumSometimes you need check, which part of radio spectrum (channel) is free for your application. The rf_scanner from advanced examples could be solution for you. Please note, that following application can not substitute professional RF scanner, but could be useful, if you have not any better measurement device.

Transmitters

As I wrote, we will use rf_scanner.c source code as base for our scanner. Also, we have to prepare some devices working as transmitters for testing. Following code shows, how to make simple transmitters with different channels. Choose two or more different channels for testing. You can use default channel 52 (just comment line) and channel 25.

#include "includes/template-basic.h"
// *********************************************************************
void APPLICATION()  
{
    appInfo();              // Copy Application data
                            // from EEPROM to bufferINFO
    copyBufferINFO2RF();    // and then copy it to bufferRF
    setRFchannel(25);       // set two or more different channels

    while (1)
    {
        if (buttonPressed)     	// If button is pressed
        {
            pulseLEDR();        // LED indication
            PIN = 0;
            DLEN = 10;
            RFTXpacket();       // Transmit the message
        }
    }
}

Receiver

You can use rf_scanner.c as is. This code runs over all channels and reads RSSI value from them. Then values are written to SPI buffer. And Again. Please note, scanning speed is not very high and SPI transmission represents another delay, which we have to assume.

#include "../../includes/template-basic.h"

// *********************************************************************
#define	MIN_CHANNEL				0
#define	MAX_CHANNEL				61

// *********************************************************************
void APPLICATION()
{
uns8 i, val;

    enableSPI();
    setRFmode(_STAYRX);    // RX chain will stay on after follow-up checkRF
    checkRF(0);            // To switch RX chain on
    waitMS(3);             // Wait until RX chain is on 
    i = MIN_CHANNEL;

    while (1)
    {
        setRFchannel(i);
        val = getRSSI();
        writeToRAM(bufferCOM + i, val);
		
        if (++i > MAX_CHANNEL)
        {
            startSPI(i);
            i = MIN_CHANNEL;
            while(getStatusSPI());	// Until the packet is picked-up
        }
    }
}

Use the IQRF IDE terminal as logger. Remove all columns inside Teminal Log. Show  the “Data DEC” column only. Then press button on the first transmitter and then on the second transmitters. You can see some changes.

If you want, you can export measured values for example as .CSV file and then make some visualisation with some spreadsheet application. Following picture shows spectrum chart made with Microsoft Excel. Red curve shows transmitter with channel 25, blue one with channel 52.

spectrum2I am going to make some simple PC application for RF scanning, so can look forward…

3 thoughts on “Simple RF scanner

  1. Sai

    Is the data showing RSSI values of all nodes in the network? Where can I download this code sample?

    Reply
    1. Profile photo of Ondřej KarasOndřej Karas Post author

      It is not IQMESH application, so from this, this shows only RSSI of one device. PC application has not been finished yet.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *