Hi all! Every time i set the role, it reverts back. As you can tell in the terminal output. I have two HC-05 modules, and both of them do this, i've tried on 3 separate micro controllers. Nano, Nano and Uno R3. Also, my address changes for my slave device, when im trying to "AT+BIND" on the master module. as you can see in the terminal output as well. Did i happen to get 2 faulty modules? Of what am i doing wrong? Thanks to anybody who can give me a hand with this!
I have the HC-05 ZS-040,
Here is also my Code
PINS:
RX>RX(3)
TX>TX(2)
Gr > GR (With 1K and 2.2K Resistor between ground and RX)
Vcc>5V
#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); // RX | TX
const long baudRate = 38400;
char c = ' ';
boolean NL = true;
void setup()
{
Serial.begin(38400);
Serial.print("Sketch: "); Serial.println(__FILE__);
Serial.print("Uploaded: "); Serial.println(__DATE__);
Serial.println(" ");
BTserial.begin(baudRate);
Serial.print("BTserial started at ");
Serial.println(baudRate);
//BTserial.print("BTserial started at ");
//BTserial.println(baudRate);
Serial.println(" ");
}
void loop()
{
// Read from the Bluetooth module and send to the Arduino Serial Monitor
if (BTserial.available())
{
c = BTserial.read();
Serial.write(c);
}
// Read from the Serial Monitor and send to the Bluetooth module
if (Serial.available())
{
c = Serial.read();
BTserial.write(c);
// Echo the user input to the main window. The ">" character indicates the user entered text.
if (NL)
{
Serial.print(">");
NL = false;
}
Serial.write(c);
if (c == 10)
{
NL = true;
}
}
}
BTserial started at 38400
>AT
OK
>AT
OK
>AT+UART?
+UART=9600,0,0
OK
>AT+UART=38400,0,0
OK
>AT+UART?
+UART=38400,0,0
OK
>AT+ROLE?
+ROLE:0
OK
>AT+ROLE=1
OK
>AT+CMODE=0
OK
>AT+ROLE?
OK
+ROLE: 0 /// Supposed to be ROLE: 1
OK
>AT+BIND=****,**,020e06
OK
>AT+BIND?
+BIND:****:**:020e26 /// 0 changes to a 2
OK