Simulating RSSI with Cheap RF Modules

1.5k views Asked by At

My goal is to essentially spoof RSSI (Received Signal Strength Indicator) using a system of counting received packets. The idea is to have something where:

  • A specific number of packets is sent in a specific time from the transmitter.

  • Then are received at another unit and the number of packets received is counted.

  • The number in the counter of the receiver indicates the number of packets received at that time specific in the transmitter.

  • The fewer packages (counter value) that are received, the farther the sender will be.

I'm having a little trouble implementing the logic in my code however so I'd really appreciate the help. I am using Arduino Pro Mini 5V with NRF24L01+ radios and the RF24 Network library. My code is as follows:

Transmitter:

#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include <Wire.h>

RF24 radio(8,9);                    

RF24Network network(radio);         

const uint16_t home_node = 00;   
const uint16_t distant_node = 01;   

struct payload_t {                  // Structure of our payload
  byte ID;
};


void setup(void) {
  Serial.begin(115200);
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 92, /*node address*/ distant_node);
}

void loop(void) {

  byte ID = 1;

  for (int i = 0; i < 50; i++)
  {
    payload_t payload = {ID};                           
    RF24NetworkHeader header(/*to node*/ home_node);
    bool ok = network.write(header,&payload,sizeof(payload));
    if (ok)
      Serial.println("ok.");
    else
      Serial.println("failed.");
    delay (300); 
  }
  delay(15000);
}

Receiver:

#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include <Wire.h>

RF24 radio(8,9);                    

RF24Network network(radio);         

const uint16_t home_node = 00;   
const uint16_t distant_node = 01;

struct payload_t {
  byte ID;
};

//const unsigned long interval = 3000; 
//unsigned long last_sent;
int count = 0;


void setup(void)
{
  Serial.begin(115200);
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 92, /*node address*/ home_node);
}

void loop(void)
{
  RF24NetworkHeader header;
  payload_t payload;
  network.update();
  while ( network.available() ) {     // Is there anything ready for us?
     bool ok = network.read(header, &payload, sizeof(payload));
     if (ok) // Non-blocking
     {
       count++;
       Serial.println ("count=");
       Serial.println (count);
     }
     else 
       Serial.println ("Failed");

  }
}
0

There are 0 answers