hello everyone. I'm new here and a newbie in arduino programming.
i just want to ask you if is it possible to loop an AT Command. btw, i'm trying to get the RSSI of a HC-05 bluetooth module. i am trying to make the arduino to continuously ask the RSSI of HC05. i have 2 HC-05 module and i already set one to a master, and another one to slave. and also i already bind the master to the slave.
Now like i said, i want to continuously ask the arduino to send an AT command to the serial monitor, like "AT+INQ just to get the RSSI of HC 05.
is it possible? because i try to loop it in setup with for loop, but it wont work. i tried also to put it in void loop, yes it loops, but it is printing randoom character and not RSSI.
please help me, im a newbie.
here is my simple code.
i know maybe you'll notice some code that i don't know that is wrong. so please teach me. thank you very much.
#include<SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); //10 is Tx, 11 is Rx
void setup() {
// put your setup code here, to run once:
BTSerial.begin(38400);
Serial.begin(38400); // opens the serial port
Serial.println("Getting RSSI Value..."); //Prints value on to the serial monitor
BTSerial.println("AT");
delay(10);
BTSerial.println("AT+INIT");
delay(10);
BTSerial.println("AT+INQ");
delay(10);
}
void loop() {
// put your main code here, to run repeatedly:
if (BTSerial.available())
{
Serial.write(BTSerial.read()); // Keep reading from HC-05 and send to Arduino Serial Monitor
}
if (Serial.available()) //Get the number of bytes (characters) available for reading from the serial portx
{
BTSerial.write((Serial.read())); // Keep reading from Arduino Serial Monitor and send to HC-05
}
}