Go Down

Topic: BLUETOOTH RSSI  (Read 203 times) previous topic - next topic

ShadowSilver

Good day everyone . I have a question about how to extract RSSI value from bluetooth module ?

We already have values and the only problem is that how to extract these values to use in IF commnad.

We want to use it to be the input of our system .

Example when the RSSI value decreases, it will trigger our prototype like to vibrate.

Advance Thank you for replies :)

PaulS

Quote
We already have values
So, what values do you now need? I hesitate to ask how you got the values you have. But, I've got a glass shield between me and you, so consider the question asked.
The art of getting good answers lies in asking good questions.

ShadowSilver

 the values that I need can be seen in the serial monitor, however I need to store it on a variable to make use of it. And that is the problem .

I believe that those are already the RSSI from the bluetooth module we use

PaulS

Quote
the values that I need can be seen in the serial monitor
Not by me.

Quote
however I need to store it on a variable to make use of it.
So, do that, then print whatever mysterious thing you are printing by printing the variable.

Quote
I believe that those are already the RSSI from the bluetooth module we use
I'll bet you believe in Santa Claus, too.

Post some code!
The art of getting good answers lies in asking good questions.

ShadowSilver

Not by me.
So, do that, then print whatever mysterious thing you are printing by printing the variable.
I'll bet you believe in Santa Claus, too.

Post some code!
here is the code we are using.. We are stuck at the part that the serial monitor shows Enter AT commands:
and no rssi values are showing

Code: ("BLUETOOTH RSSI") [Select]


#include <SoftwareSerial.h>

SoftwareSerial BTSerial(10, 11); // RX | TX

String Setup_test = " ";
String Signal = " ";
String attempt = "OK\r\n";
String Rssi = " ";
int nombre_de_mesure = 5; // A changer ici et plus bas dans inqm!
int laenge = ' ';
int a;
long somme = 0;
long amplitude_du_signal = ' ';
long fixe = 0;


void setup()
{
  Serial.begin(9600);
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400);  // HC-05 default speed in AT command more
  BTSerial.write("at+reset\r\n");
  Setup_test = BTSerial.readString();
  while (Setup_test != attempt){
     Setup_test = BTSerial.readString();
  }
  Serial.print(Setup_test);
  BTSerial.write("at+cmode=1\r\n");
  Setup_test = BTSerial.readString();
  while (Setup_test != attempt){
     Setup_test = BTSerial.readString();
  }
  Serial.print(Setup_test);
  BTSerial.write("at+inqm=1,5,48\r\n");    //nombre_de_mesure a chang√© ici egalement
  Setup_test = BTSerial.readString();
  while (Setup_test != attempt){
     Setup_test = BTSerial.readString();
  }
  Serial.print(Setup_test);
  BTSerial.write("at+init\r\n");
  Setup_test = BTSerial.readString();
  while (Setup_test != attempt){
     Setup_test = BTSerial.readString();
  }
  Serial.print(Setup_test);
}

void loop()
{


BTSerial.write("at+inq\r\n");
  Signal = " ";
  fixe = 0;
  a = 0;
  // Le temps que HC 05 n'a pas repondu attend une reponse
  while (Signal.startsWith(" ",0)){
  if (BTSerial.available()) {

    Signal = BTSerial.readString();
    Serial.print(Signal);
    laenge = ((Signal.length()-2)/(nombre_de_mesure));
      for (int i = 0; i < (nombre_de_mesure+1);i++){
        Rssi = Signal.substring((i*laenge)+(laenge-6),(i*laenge)+laenge);
        char rssi[5] = {Rssi.charAt(0),Rssi.charAt(1),Rssi.charAt(2),Rssi.charAt(3)};
        somme = strtol(rssi, NULL, 16);  //Convertir le contenu du String Rssi (4 lettres / chiffres ex: FFBC) en DECimal (convertir de hexa en decimal) puis mettre le long somme √† la valeur du String Rssi
        fixe = fixe + somme; //Faire la somme des differentes valeurs de signal Rssi      
        a++;
//        Serial.print(Rssi);        
    }
  }
 }
     amplitude_du_signal = fixe/a;
     Serial.print(amplitude_du_signal);

    }








PaulS

Code: [Select]
int laenge = ' ';
int a;
long somme = 0;
long amplitude_du_signal = ' ';

Why are you initializing non-character variables with character values?

Quote
We are stuck at the part that the serial monitor shows Enter AT commands
You send data to the bluetooth device. It should generate a response, after having time to process the data. You are expecting an instantaneous response, AND you are expecting that response to be "OK\r\n". If it is not, you just keep reading, and hoping that sooner or later, that exact response will arrive. You don't even bother printing the response, to see what, if anything, the response was.

I can't begin to fathom why not.
The art of getting good answers lies in asking good questions.

ShadowSilver

we are not receiving any response from the bluetooth, the hc05 module works properly however when it comes to automatically requesting the rssi values using that code, there seems to be no response from the bluetooth

knut_ny

AT-commands are case sensitive (for most modems)  To be safe: use CAPS
Ny

Go Up