Go Down

Topic: HC-05 bluetooth how to read RSSI (Read 3559 times) previous topic - next topic

__Mitnick__

I am using HC-05 bluetooth module and I got RSSI values but they're in HEX. I want to somehow convert them to -dBm and later display it. Google says nothing. I'm using Arduino Mega 2560.

My code in Arduino
Code: [Select]

char c = ' ';
byte AtmodePin = 2;
 
void setup()
{
    pinMode(AtmodePin, OUTPUT);
    digitalWrite(AtmodePin, LOW);
   
    Serial.begin(9600);
    Serial.println("Serial 0 ON");
 
    Serial1.begin(9600); 
    Serial.println("Serial 1 ON");
}
 
void loop()
{
    if (Serial1.available())
    { 
        c = Serial1.read();
        Serial.write(c);
    }
 
    if (Serial.available())
    {
        c =  Serial.read();

        if (c == '#')
        {
          digitalWrite(AtmodePin, HIGH);
          Serial.print("AT mode ON. $ zeby wyjsc");
        }

        else if (c == '$')
        {
          digitalWrite(AtmodePin, LOW);
          Serial1.print("AT+RESET\n\r");
          Serial.print("AT+RESET\n\r");
        }

        else
        {
        Serial.write(c);
        Serial1.write(c); 
        }
    }
 
}


There is what HC-05 dumps, especially last digits in row (RSSI)
Code: [Select]

AT+INQ
+INQ:E4F8:EF:C17131,5A020C,FFC4
+INQ:E4F8:EF:C17131,5A020C,FFC0
+INQ:E4F8:EF:C17131,5A020C,FFB7
+INQ:E4F8:EF:C17131,5A020C,FFBF
+INQ:E4F8:EF:C17131,5A020C,FFBC
+INQ:E4F8:EF:C17131,5A020C,FFB7
+INQ:E4F8:EF:C17131,5A020C,FFC1
+INQ:E4F8:EF:C17131,5A020C,FFBE
+INQ:E4F8:EF:C17131,5A020C,FFC6
OK

PaulS

Quote
There is what HC-05 dumps, especially last digits in row (RSSI)
Store the data in a string, instead of just printing (incorrectly) one character at a time.

Once you have stored the data in an array, until the end-of-record marker arrives, use strtok() to parse the string. Use strtoul() to convert the token to an unsigned long (or use strtol() to convert to a long).
The art of getting good answers lies in asking good questions.

Go Up