Cheap UHF spectrum analyzer (and RC tx rx) using RFM22 module

Dfidalgo:
Today I received the Zitron PCB's, look much better in my hands than here in the pictures ! :smiley:
Now just need to buy the RFM22.

Cool! Let me know how it goes!

Mauzer:
What differences are between RFM22-S1 and RFM22-S2? Only the crystal size?

I heard someone mention that the bigger crystals have better frequency tolerances, but that could be just a rumour.

Hi guys,

For those of you building the board, here's a test code to make sure that the ATMEGA is working. It simply blinks the red and green LEDs:

#define OUTA 18
#define OUTB 19

unsigned int duration = 500;

void setup()
{
  pinMode(OUTA, OUTPUT);
  pinMode(OUTB, OUTPUT);
}

void loop()
{
    digitalWrite(OUTA,HIGH);
    digitalWrite(OUTB,LOW);
    delay(duration);
    digitalWrite(OUTB,HIGH);
    digitalWrite(OUTA,LOW);
    delay(duration);
}

I got my parts together now for a build of Zitrons latest board.

Works fine with the 'blink' test program.

When trying to compile the specan.pde - I get lots of errors due to missing files...
FastSerial.h
RF22.h
C++.h
Menu.h -- and many more.

@ Zitron,
I guess you use other library files when making your specan & Tx/Rx firmwares.

Is there some single download I can get the required lib files or do I need to hunt them down individually?

EDIT
Tracked down a bunch of missing lib files and now the only remaining compile error is:

C:\Arduino\arduino-0023\libraries\RF22\RF22_Specan.cpp:379: error: prototype for 'boolean RF22::setFrequency(float)' does not match any in class 'RF22'
C:\Arduino\arduino-0023\libraries\RF22/RF22.h:813: error: candidate is: boolean RF22::setFrequency(float, float)

What do I need to change/add??

/EDIT

So close and yet so far !!

Nigel.

Hi Great Find this Good work !!!!!!!

I downloaded the programs and Pde. but i get compilation errors almost so much that it looks like im missing a library , can some one please confirm this ? i have played with the RF22 modules alot so i have the RF22.h libraries but i cant get this source code to compile

any help would be great

Hi,

I knew there would be problems!

Which version of arduino are you using? I'm using 0023, I have not tested it on version 1.0.

Try this version of the specscan without the fastserial stuff:

// rf22_specan
// A simple spectrum analyser for the RF22
// Uses the RSSI measurement to plot signal strength
// against frequency
// Specify the start and and requencies and the step size below.
// The output is suitable for a VT100 terminal emulator
// Note the baud rate is set to 115200 for better performance,
// but you can change this to suit your needs
//
// TO DO: add some interactivity
// Copyright Mike McCauley

// modified to work with PC program
// Zitron

#include <RF22.h>
#include <SPI.h>
#include<stdlib.h>

#define redLED 18
#define greenLED 19

char temp[51];
uint8_t rssi;
// Singleton instance of the radio
RF22 rf22;

void setup() 
{
  pinMode(redLED, OUTPUT);
  pinMode(greenLED, OUTPUT);
  
  Serial.begin(115200);
  if (!rf22.init())
    Serial.println("RF22 init failed");

  rf22.setModemConfig(RF22::GFSK_Rb2Fd5);
  rf22.setModeRx();
  // Defaults after init are 434.0MHz, modulation GFSK_Rb2_4Fd36
  digitalWrite(greenLED, HIGH);
}

float Start = 430;
float End = 460;
float Step = 0.1;

float freq;

void loop()
{
  ProcessRx();
  
  for (freq = Start; freq < End; freq += Step)
  {
    rf22.setFrequency(freq);
    digitalWrite(redLED, LOW);
    delayMicroseconds(6000); // Let the freq settle
    digitalWrite(redLED, HIGH);
    rssi = rf22.rssiRead();
    
    
    Serial.print(rssi, DEC);
    Serial.print(",");
    
    //Serial.println(dtostrf(freq,0,3,temp));
  } 
  Serial.println();
  //Serial.println("");
}

void ProcessRx() {
  byte n = 0;
  byte m = 0;
  char* sptr1;
  char* tempstr;

  if (Serial.available()) {
    temp[n] = Serial.read();
    while ((temp[n] != '\n')&&(n<50)) {
      if (Serial.available()) {
        n++;
        temp[n] = Serial.read();
      }
    }

    //Serial.println(temp);

    tempstr = strtok_r(temp,",\n",&sptr1);

    do
    {
      switch (m) {
      case 0:  // Wheel 1
        Start = atof(tempstr);
        break;
      case 1:  // Wheel 2
        End = atof(tempstr);
        break;
      case 2:  // Wheel 3
        Step = atof(tempstr);
        break;
      
      }
      m++;
    }
    while (tempstr = strtok_r(NULL, ",\n",&sptr1));
  }
}

I have also uploaded my modified version of the RF22 lib.

RF22.zip (381 KB)

Hi

I loaded both versions now and they seem to work great . thanx , one question , they PC application seem to very slow updating the graph

Rustie0125:
Hi

I loaded both versions now and they seem to work great . thanx , one question , they PC application seem to very slow updating the graph

Update speed depends on how many steps you are scanning. By default it scans from 430-460MHz at 0.1MHz step (300 samples), which is a bit slow. You can make it faster by increasing the step size or reducing frequency range.

BTW are you using your own board??

yes im running a RF22 on a R3 UNO .

just few questions to clarify if what im seing is correct.
below is a picture of a test running currently running on the bench.

if you look at the picture with only the RF22 switched on that is working as the receiver it would appear that there is a very high signal detected in the UHF range where i stay ? or am I seing it wrong ?

also the labeling of the dBs on the left hand side would it not make more sence if it started form -120 at the top and -20 at the bottom? I arleady made the mistake at looking at the spike but in reality if i understand it correct is actually the lowest detected frequency that im looking at , can it be swapped ?

other question is , I have a 17cm antenna on my receiver this would offcourse make a differences for freq. in the 800 or 900 range . what then ? or is this meant to be used with Rf probes only and not general area scanning ?

thanx for any advice , really keen on useing this more

Hi Z,

I'm also using 0023.

I made a clean install on netbook and copied your RF22 library (from your post above) into the clean libraries folder.
Copied the code (from above) and made a new pde called 'rf22_specan_simple' and veried it.
It compiled OK.

Ran up your RF22SpecScan.exe and it runs fine.

I'll try some more later on my main PC and Laptop as this is where I want to mostly use it.

Nigel.

rf22_specan_simple.zip (1.29 KB)

Devonian:
Hi Z,

I'm also using 0023.

I made a clean install on netbook and copied your RF22 library (from your post above) into the clean libraries folder.
Copied the code (from above) and made a new pde called 'rf22_specan_simple' and veried it.
It compiled OK.

Ran up your RF22SpecScan.exe and it runs fine.

I'll try some more later on my main PC and Laptop as this is where I want to mostly use it.

Nigel.

OK that's good.

Rustie0125:
if you look at the picture with only the RF22 switched on that is working as the receiver it would appear that there is a very high signal detected in the UHF range where i stay ? or am I seing it wrong ?

also the labeling of the dBs on the left hand side would it not make more sence if it started form -120 at the top and -20 at the bottom? I arleady made the mistake at looking at the spike but in reality if i understand it correct is actually the lowest detected frequency that im looking at , can it be swapped ?

That looks pretty normal. The RF22 is not meant to be a spectrum analyzer, it will only work properly for the frequency range the module and antenna is made for. You can force it to whatever frequency you want, but results will not be accurate.

RSSI is a logarithmic scale, you are reading it wrong. See dBm - Wikipedia

I just remembered that that I have made some small improvements to the PC program, I have attached the new version.

RF22SpecScan V0.11.zip (193 KB)

Okay

thanx for confirming that . so for example if the RF22 radio max output is 17-20dBs then if i transmit next the the analyzer i will see a 20 dB jump in the graph but so if it was -120 it will be -100 or around there.

regarding the Antenna issue , all i really wanna test with these unit is if RF equipments is working or not. for example if i have a 433mhz remote i just want to Tx next to it and see a jump in the graph so Accuracy is not that big of a problem. what i think i would do is make a small Antenna relay board with antenna's made for 900mhz, 433mhz and 600mhz and when i switch between them the reply will latch to the correct antenna Automatically i know its not the best but i think it will be best this setup can do.

are you planning on upgrading the Pc app with more functions ?

like to see if you can set a start line on the average incoming signal and the app will update the max output line at the top of the graph and under the setting just show a tab that updates the dB difference between the two lines.

but thank you for all the advice and info looking forward hearing form you regarding the boards

This is and excellent project! :slight_smile:
I really want to try it out in my FPV quads.

Does anyone has PCB's to sell?
Unfortunately I have no way to make them.
(well I could but I'd probably ended up sleeping in the balcony)

Thanks!

This is exactly what this is - a DIY project.

It would be nearly the same cost to make a few by hand and sell to you as it would be to buy commercially.

Have you seen this?
http://flytron.com/16-openlrs

Forum support as well
http://forum.flytron.com/viewforum.php?f=7&sid=5794eb0b6f028f25cacb8b980bba52fa

HTH

Nigel.

Rustie0125:
thanx for confirming that . so for example if the RF22 radio max output is 17-20dBs then if i transmit next the the analyzer i will see a 20 dB jump in the graph but so if it was -120 it will be -100 or around there.

You will only see a 20dB jump if you were perviously transmitting at 0dB! Theoretically, if you are transmitting at 0dBm (1mW), and connect the tx directly to the rx with a coax cable (do not do this!) you will see 0dBm on the receiver. However in real life and if you are using antennas, you will see the rx RSSI change from about -20 (the RF22 will not report RSSI higher than -20) to -100 as you move the rx away from the tx.

Rustie0125:
regarding the Antenna issue , all i really wanna test with these unit is if RF equipments is working or not. for example if i have a 433mhz remote i just want to Tx next to it and see a jump in the graph so Accuracy is not that big of a problem. what i think i would do is make a small Antenna relay board with antenna's made for 900mhz, 433mhz and 600mhz and when i switch between them the reply will latch to the correct antenna Automatically i know its not the best but i think it will be best this setup can do.

are you planning on upgrading the Pc app with more functions ?

like to see if you can set a start line on the average incoming signal and the app will update the max output line at the top of the graph and under the setting just show a tab that updates the dB difference between the two lines.

That will probably work ok, but you will need to write your own code. I might add more to the PC program, but it's not really a priority. You can do your own data processing by collecting the serial data and plotting them in MS Excel or MatLab or even do it on the arduino chip.

Nandox7:
This is and excellent project! :slight_smile:
I really want to try it out in my FPV quads.

Does anyone has PCB's to sell?
Unfortunately I have no way to make them.
(well I could but I'd probably ended up sleeping in the balcony)

Thanks!

Basically what Devonian said. If you want one or two boards that work right out of the box, you are better off getting the openlrs. I only have the bare pcbs.

BTW, Nigel did you get the thing working on your main PC? If your boards are working properly I'll put together some RC PPM code this weekend for you to test. I've not really been motivated to do much this past week because of the terrible weather!

Hi Z,

My first board works just fine as a spec analyser.
I've yet to build my other boards.

I'm a bit like you, no big motivation for UHF at the moment (I have OpenLRS for UHF R/C), plus I have a couple other projects - including weather monitoring, maybe with an RFM22B and an Arduino :wink:
With the British weather, you should get on it !

Nigel.

zitron:
Basically what Devonian said. If you want one or two boards that work right out of the box, you are better off getting the openlrs. I only have the bare pcbs.

My problem sorry, I wasn't that clear.
I'm more of the soldering station type, I prefer to assembly my own gear. :slight_smile:

I know about Flytron gear I actually bought some other parts from them, but yes my intention is to get bare PCB's.
I have all the remaining parts just the PCB that is missing.

I got some time ago some similar RFM boards (RFM21 I believe) to do a telemetry project but got sidetracked and ended
going for BlueTooth and developing an app for it. And the the boards are still here getting dust.

But what you share here is on a another level (special in what concerns range) and rather interests me, so I eager to try it
and put my hands on the code as well. :slight_smile:

PS: I got you guys on the weather (Ireland here)

Hi zitron,

Where did you get your RFM22B? The only that I can find seem to have the emitting power locked and can't do the 100mW.

Thanks

Nandox7:
Hi zitron,

Where did you get your RFM22B? The only that I can find seem to have the emitting power locked and can't do the 100mW.

Thanks

Nandox7:
I know about Flytron gear I actually bought some other parts from them, but yes my intention is to get bare PCB's.
I have all the remaining parts just the PCB that is missing.

I got some time ago some similar RFM boards (RFM21 I believe) to do a telemetry project but got sidetracked and ended
going for BlueTooth and developing an app for it. And the the boards are still here getting dust.

But what you share here is on a another level (special in what concerns range) and rather interests me, so I eager to try it
and put my hands on the code as well. :slight_smile:

Oh, does that mean you can help with the code?? I have 4 boards left, Rustie0125 wants 1, so you can have the last 3. PM me your address, email and how many you want.

Devonian:
My first board works just fine as a spec analyser.
I've yet to build my other boards.

I'm a bit like you, no big motivation for UHF at the moment (I have OpenLRS for UHF R/C), plus I have a couple other projects - including weather monitoring, maybe with an RFM22B and an Arduino :wink:

Cool. I can help you with the code if your weather telemetry project is something simple, like tx/rx of serial data or something.

Hi Z,

I'm gathering together some bits as the data is apparantly sent over 433.92MHz AM radio by OOK (On-Off-Keying) and there is some info on the 'tinterweb about the protocols used.

I may just get another weather station with serial out on the receiving consol and do it that way.

I also have a Raspberry Pi on order (for ages now), maybe a low power web server and automatic weather station??!!

Too many projects and not enough time...!

Nigel.