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

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)