0
嗨,我是韓國的大學生。我正在做一個使用bluno nano的項目。我想要在Bluno素描上獲得Integer RSSI值。我在串口監視器上做了。命令「AT + RSSI =?」工作得很好。但是,我想要素描。我該怎麼做?如何獲取Bluno nano草圖上的RSSI值?
我在這個網站上使用了這段代碼。雖然我將android和iPhone連接到bluno,但在串行監視器上通知0和0.00值。 有什麼問題?來人幫幫我!
// while the AT connection is active, the serial port between the pc and the arduino is occuipied.
// You can manipluate the data on arduino, but to display on the serial monitor you need to exit the AT mode
char Data[100];
char RAW[3];
int INDEX;
char Value = '-';
void setup() {
pinMode(13, OUTPUT); // This the onboard LED
pinMode(8, OUTPUT); // This is connected to the buzzer
Serial.begin(115200); //Initiate the Serial comm
Serial.print("+");
Serial.print("+");
Serial.print("+"); // Enter the AT mode
delay(500); // Slow down and wait for connectin establishment
}
void loop(){
Serial.println("AT+RSSI=?"); // Ask about the RSSI
for(int x=0 ; Serial.available() > 0 ; x++){ // get the Enter AT mode words
//delay(20); // Slow down for accuracy
Data[x] = Serial.read(); // Read and store Data Byte by Byte
if (Data[x] == Value) // Look for the elemnt of the array that have "-" that's the start of the RSSI value
{
INDEX=x;
}
}
//Serial.println("AT+EXIT");
RAW[0] = Data[INDEX]; // Copy the RSSI value to RAW Char array
RAW[1] = Data[INDEX+1];
RAW[2] = Data[INDEX+2];
RAW[3] = Data[INDEX+3];
int RSSI = atoi(RAW); //Convert the Array to an integer
//Serial.println(RSSI);
//delay(200); // Give the program time to process. Serial Comm sucks
double D = exp(((RSSI+60)/-10)); //Calculate the distance but this is VERY inaccurate
//Serial.println(D);
if (D>1.00) // If the device gets far, excute the following>>
{
digitalWrite(13, HIGH);
digitalWrite(8, HIGH);
delay(500);
digitalWrite(13, LOW);
digitalWrite(8, LOW);
delay(500);
}
}
這種類型的迴應並不是一個真正的答案,而是一個評論。一旦你獲得了足夠的聲望,你可以添加評論。 – arcresu