Go Down

Topic: Simulating RSSI with Cheap RF Modules (Read 906 times) previous topic - next topic

archeresque

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:

Code: [Select]
#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:

Code: [Select]
#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");

  }


}


Thank you!

mauried

Doesnt work like that as RSSI (signal strength) isnt a linear function with those cheap modules.
The demodulation function is more like a knife edge where above a certain signal strength they work extremely well, and below that they dont work at all.
In addition there is the problem of interferance as the frequency they use (433.92) is also used by many other
devices and this can affect the error rate.
But RSSI is a useless method of measuring distance anyway as there are too many other variables that can affect it.

archeresque

Now I could be completely wrong but I think the radio module I'm using should have some play in the demodulation function but I think I need to add a time limit or all the packets will always make it to the other side. The interference could be a problem however I didn't take that into account because it is essentially the wifi band. As for RSSI, alone its not very good for determining distance, but I want to establish an approximate relationship between distance and the number of packets received and then use this data to triangulate an approximate position. I know this isn't an exact science by any stretch but I'm looking for general area rather than a precise spot somewhere. Thoughts? Thanks for taking the time to reply as well.

mauried

Sorry I missed the bit where you were using the NRF24l01.
The problem though is the same .
The NRF24l01 uses GFSK as the modulation scheme, and the problem you will encounter is that above a carrier to noise ratio of around 12 db , the bit error rate rapidly falls, around 1 error in 10 million, so trying to determine distance vs bit error rate wont yield any useful result, especially in the 2.4 Ghz ISM band where there are interfering signals.
But as I mentioned before RSSI is a hopeless way of measuring distance, even if you have a radio with a true
RSSI output.


archeresque

I did some reading on the NRF24L01+ and you're right, the error isn't anywhere near to something that could be useful. I'm thinking of switching to a 433 mHz transmitter/receiver pair which should yield a usable error rate. I think if I switch to these I can better establish a relationship between distance and packet reception. The goal isn't to deriev an exact distance but to set up a few units and approximate position. I've seen threads online such as this and this where it seems possible. You clearly know your radios very well so what do you think about a different radio? And thank you again for being so helpful.

srnet

I did some reading on the NRF24L01+ and you're right, the error isn't anywhere near to something that could be useful. I'm thinking of switching to a 433 mHz transmitter/receiver pair which should yield a usable error rate. I think if I switch to these I can better establish a relationship between distance and packet reception. The goal isn't to deriev an exact distance but to set up a few units and approximate position. I've seen threads online such as this and this where it seems possible. You clearly know your radios very well so what do you think about a different radio? And thank you again for being so helpful.
There are several 433Mhz radio modules out there that will give you RSSI but in a lot of locations (and I have  a good deal of practical experince in this area) you may get an indication that the distance is 100M move a couple of meteres only and its 300M, not very useful at all really.

Lots of people have this 'dea' that you can use RSS1 for distance measurement and triangulation, it gets asked on here every couple of days.

If it were a useful method of measuring distance, then there ought to be zillions of worked examples of it working. I cant recall seeing one.

$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

archeresque

Lots of people have this 'idea' that you can use RSS1 for distance measurement and triangulation, it gets asked on here every couple of days.

If it were a useful method of measuring distance, then there ought to be zillions of worked examples of it working. I cant recall seeing one.

Hmm, then how would you recommend a DIY solution to position tracking then? I only need to know if a tag is located in a specific room, accuracy to a couple inches etc, is not necessary.

srnet

Hmm, then how would you recommend a DIY solution to position tracking then? I only need to know if a tag is located in a specific room, accuracy to a couple inches etc, is not necessary.
So you want to 'track' people to specific rooms ?

Is there a reason why you did not describe this requirement in your original post ?

You have also not explained at all what it is you are actually trying to do or indeed why ?

$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

archeresque

So you want to 'track' people to specific rooms ?

Is there a reason why you did not describe this requirement in your original post ?

You have also not explained at all what it is you are actually trying to do or indeed why ?


I apologize I wasn't being clear. This is a personal project I want to use as a proof of concept. I wanted to track my pets inside the house and I learned that indoor positioning systems were quite pricy so I tried to make my own using cheap parts but clever logic. My goal is to track within about a meter accuracy but I figured it would be best to start by just knowing whether the tracked animal was in a specific room to start and go from there. Eventually I would like to expand the idea to other applications while still keeping a lower materials cost than other consumer or DIY solutions. In theory, packet counting would work but you need a radio with a linear signal to distance ratio which is easier said than done apparently.

jremington

#9
Sep 12, 2017, 12:11 am Last Edit: Sep 12, 2017, 12:14 am by jremington
Indoor positioning systems are "quite pricy" because indoor positioning is a very difficult problem.

If there were a cheap way to do it, it would have been done many years ago.

PS: some estimates claim that the GPS outdoor positioning system cost about $4 billion to implement.

srnet

I apologize I wasn't being clear. This is a personal project I want to use as a proof of concept. I wanted to track my pets inside the house and I learned that indoor positioning systems were quite pricy so I tried to make my own using cheap parts but clever logic. My goal is to track within about a meter accuracy but I figured it would be best to start by just knowing whether the tracked animal was in a specific room to start and go from there. Eventually I would like to expand the idea to other applications while still keeping a lower materials cost than other consumer or DIY solutions.
Unfortuantely your logic appears to be based on an incomplete appreciation of how much signal strength can vary, especially  indoors, due to reflections and realtive antenna orientation. A few simple tests using a radio module that gives a direct RSSI output would confirm this. 


Quote
In theory, packet counting would work but you need a radio with a linear signal to distance ratio which is easier said than done apparently.
In 'theory' packet counting would be a great deal more crude than using a module with proper RSSI, so pretty pointless really.

And its not that you need a 'radio' with a linear signal to distance ratio, electromagnetic wave do degrade according to a square law (twice the distance four times less signal etc), you need to remove all the issues relating to antenna orientation and signal reflections.

$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

archeresque

And its not that you need a 'radio' with a linear signal to distance ratio, electromagnetic wave do degrade according to a square law (twice the distance four times less signal etc), you need to remove all the issues relating to antenna orientation and signal reflections.
So would you say continuing this project in this manner is pointless or do I need to retool my approach taking into account more variables such as antenna orientation, signal reflection, degradation etc, as you pointed out?

jremington

#12
Sep 12, 2017, 09:23 pm Last Edit: Sep 12, 2017, 09:26 pm by jremington
Your idea won't work; consider the effort as part of a learning situation.

srnet

So would you say continuing this project in this manner is pointless or do I need to retool my approach taking into account more variables such as antenna orientation, signal reflection, degradation etc, as you pointed out?
Several suggestions have been made, have you considered carrying out some practical experiments ?
$50SAT is now Silent (but probably still running)
http://www.50dollarsat.info/
http://www.loratracker.uk/

archeresque

Several suggestions have been made, have you considered carrying out some practical experiments ?
I have with the nRF24l01+ but the results were disappointing and after more research I know why this radio didn't work. I ordered a few more radios that should be here in the coming days and I will update the threads I've started with anything I've learned. Even if this project falls through using this specific method, I think I have the radio bug and I'm excited to learn more about wireless communication.

Go Up