In some environments there is already a lot of traffic on the 868MHz band. The JeeNodes all send on the same "slot" in this band. If you lose a lot of packets It could be that there are other devices using the same frequency.
Therefore it would be nice to "see" what is going on in the air. Spectrum analyzers, especially for wireless applications are quit expensive. There is no way to implement a real spectrum analyzer with a JeeNode.
Nevertheless I had once an idea how to do something in this direction. The RFM12B module has an RSSI functionality which tells you if something is going on in the tuned frequency. If we change the frequency from the beginning to the end of the 868MHz band, and check every time for the RSSI value, we can get some information about the activity on the different frequencies. All this approach needs is enough time.
The following code is a first basic try. A proof of concept if you like. It outputs values which make sense on the first glimpse. But as I not posses a real spectrum analyzer I have no possibilities to verify this data. Also I have no GUI part for the code, this also would give more information out of the data.
First we need to add some low level extensions in the RF12.cpp
void rf12changeFreq (uint16t frequency) {
cli();
rf12xfer(0xA000 | frequency);
sei();
}
void rf12changeRSSI (uint8t sens) {
cli();
rf12xfer(0x94A0 | sens); //0 = -103dBm, 1 = -97dBm, 2 = -91dBm, 3 = -85dBm, 4 = -79dBm, 5 = -73dBm
sei();
}
uint8t rf12RSSI () {
cli(); // start critical section so we can call rf12xfer() safely
if (rf12xfer(0x0000) & RFRSSIBIT) {// carrier sensed: we're over the RSSI threshold
sei(); // end critical section
return 1;
}
sei();
return 0;
}
An the matching entries in the RF12.h
void (rf12changeFreq) (uint16t);
uint8t (rf12RSSI) (void);
void (rf12changeRSSI) (uint8t);
With this modifications we can run the following sketch
// Spectrum Analyzer, proof of concept code
// 2010-06-20 #include "Ports.h"
#include "RF12.h" uint16t freq = 96;
void setup() {
rf12initialize('B', RF12868MHZ);
Serial.begin(57600);
} void loop() {
if (freq <= 3903) freq += 8; // increase the frequency
else {
Serial.println("");
freq = 96; // jump to the beginning of the RF12 covered band
}
delay(1);
rf12changeFreq(freq);
rf12recvDone(); // get the module tuned
// Serial.println(rf12RSSI(),BIN);
if(rf12RSSI()){ // something on air?
Serial.print(20 (43 + (freq / 4000.00)), DEC);
rf12changeRSSI(2); // set to second lowest RSSI sensing
if(rf12RSSI()){ // something found step one RSSI level up
Serial.print(" 2");
rf12changeRSSI(3);
if(rf12RSSI()){ // and once up again
Serial.print(" 3");
rf12changeRSSI(4);
if(rf12RSSI()){ // and last time
Serial.print(" 4");
}
}
}
Serial.println(";");
rf12changeRSSI(1); // and back to lowest RSSI sensing
}
}
Improvements and todo:
- Real life check with a real Spectrum Analyzer. - Tuning of the delay function, it could be that the module doesn't get enough time to tune to the new frequency. - GUI - Aggregation of the sensed data in time, in the EEPROM or RAM.
